Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Hereβs a clean, detailed, and ready-to-go `README.md` for your Hugging Face repo! πβ¨
|
| 2 |
+
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
## π©Έ **Cycle Sync: Menstrual Cycle Prediction using LSTM**
|
| 6 |
+
|
| 7 |
+
### π **Model Overview**
|
| 8 |
+
The `cycle-sync` model is built using a Long Short-Term Memory (LSTM) architecture trained to predict menstrual cycle lengths and period durations based on a userβs past period history.
|
| 9 |
+
|
| 10 |
+
### π₯ **Model Highlights**
|
| 11 |
+
- π§ **Architecture:** LSTM (Long Short-Term Memory) with time-series inputs.
|
| 12 |
+
- π **Purpose:** Predict the next period start date and duration based on previous cycle data.
|
| 13 |
+
- π― **Task Type:** `time-series-forecasting`
|
| 14 |
+
- π **Framework:** Keras with TensorFlow backend.
|
| 15 |
+
- π **Scalers:** `MinMaxScaler` used for feature and label scaling.
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
## π‘ **Usage**
|
| 20 |
+
|
| 21 |
+
### π¨ **Load Model**
|
| 22 |
+
To load the model from Hugging Face, use the following code:
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
import keras
|
| 26 |
+
from datetime import timedelta
|
| 27 |
+
import numpy as np
|
| 28 |
+
import pickle
|
| 29 |
+
|
| 30 |
+
# Load the model from Hugging Face
|
| 31 |
+
model = keras.saving.load_model("hf://VishSinh/cycle-sync")
|
| 32 |
+
|
| 33 |
+
# Load the scalers (if needed)
|
| 34 |
+
with open("feature_scaler.pkl", "rb") as f:
|
| 35 |
+
feature_scaler = pickle.load(f)
|
| 36 |
+
|
| 37 |
+
with open("label_scaler.pkl", "rb") as f:
|
| 38 |
+
label_scaler = pickle.load(f)
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π **Input & Output Schema**
|
| 44 |
+
|
| 45 |
+
### π₯ **Input Format**
|
| 46 |
+
The model expects a 3D input of shape:
|
| 47 |
+
```
|
| 48 |
+
(1, 3, 2)
|
| 49 |
+
```
|
| 50 |
+
- **3**: Number of previous cycles used for prediction.
|
| 51 |
+
- **2**: Features - cycle length and period duration.
|
| 52 |
+
|
| 53 |
+
### π€ **Output Format**
|
| 54 |
+
The model outputs a 1D array:
|
| 55 |
+
```
|
| 56 |
+
[cycle_length, period_duration]
|
| 57 |
+
```
|
| 58 |
+
- `cycle_length`: Predicted length of the next cycle.
|
| 59 |
+
- `period_duration`: Predicted duration of the next period.
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## π― **Prediction Example**
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
# Example input: 3 cycles with lengths and durations
|
| 67 |
+
last_three_cycles = np.array([[[28, 5], [29, 5], [30, 6]]])
|
| 68 |
+
|
| 69 |
+
# Scale the input
|
| 70 |
+
input_flat = last_three_cycles.reshape(-1, 2)
|
| 71 |
+
input_scaled_flat = feature_scaler.transform(input_flat)
|
| 72 |
+
input_scaled = input_scaled_flat.reshape(1, 3, 2)
|
| 73 |
+
|
| 74 |
+
# Make prediction
|
| 75 |
+
prediction_scaled = model.predict(input_scaled)
|
| 76 |
+
prediction = label_scaler.inverse_transform(prediction_scaled)[0]
|
| 77 |
+
|
| 78 |
+
# Extract predicted values
|
| 79 |
+
next_cycle_length = round(prediction[0])
|
| 80 |
+
next_period_duration = round(prediction[1])
|
| 81 |
+
|
| 82 |
+
print(f"Predicted Next Cycle Length: {next_cycle_length} days")
|
| 83 |
+
print(f"Predicted Period Duration: {next_period_duration} days")
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## π **Training Details**
|
| 89 |
+
- **Data Sources:** Synthetic and real menstrual cycle data.
|
| 90 |
+
- **Model Architecture:** 2-layer LSTM with dropout and dense output.
|
| 91 |
+
- **Loss Function:** Mean Squared Error (MSE)
|
| 92 |
+
- **Optimizer:** Adam
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## π **Evaluation Metrics**
|
| 97 |
+
- π **MAE:** ~1.2
|
| 98 |
+
- π **MSE:** ~2.5
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## π **License**
|
| 103 |
+
This model is licensed under the Apache 2.0 License.
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## π€ **Contributing**
|
| 108 |
+
We welcome contributions! Please open an issue or submit a pull request if youβd like to improve the model or documentation.
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## β€οΈ **Acknowledgements**
|
| 113 |
+
Special thanks to the healthcare community and menstrual health advocates who contributed to building this predictive model.
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
π **Ready to predict and empower users with data-driven cycle predictions!** π‘
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
Let me know if you need help uploading or tweaking this! ππ
|