shamique commited on
Commit
0d030e6
·
verified ·
1 Parent(s): b70095f

Update model card with 100-subject benchmark results (3 seeds × 10 folds)

Browse files
Files changed (1) hide show
  1. README.md +45 -57
README.md CHANGED
@@ -52,35 +52,27 @@ model-index:
52
  name: Sleep Stage Classification
53
  dataset:
54
  type: sleep-edf-expanded
55
- name: Sleep-EDF Expanded (15 subjects, PhysioNet)
56
  config: default
57
  split: test
58
  revision: main
59
  metrics:
60
  - type: accuracy
61
- value: 0.930
62
  name: Accuracy
63
  verified: false
64
  - type: cohen_kappa
65
- value: 0.861
66
  name: Cohen's Kappa
67
  verified: false
68
  - type: f1
69
- value: 0.794
70
  name: Macro F1
71
  verified: false
72
  - type: f1
73
- value: 0.935
74
  name: Weighted F1
75
  verified: false
76
- - type: f1
77
- value: 0.455
78
- name: N1 F1
79
- verified: false
80
- - type: f1
81
- value: 0.803
82
- name: REM F1
83
- verified: false
84
  widget:
85
  - src: https://huggingface.co/spaces/shamique/neurosleep-demo
86
  title: NeuroSleep Live Demo
@@ -90,9 +82,9 @@ widget:
90
 
91
  # NeuroSleep — Light-Weight Sleep Stage Model
92
 
93
- **99,477 parameters, 93% accuracy (κ=0.86) — small enough for edge/wearable deployment, scoring Wake/N1/N2/N3/REM from 4-channel PSG.**
94
 
95
- > **Quick links:** [GitHub](https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline) · [Live Demo](https://huggingface.co/spaces/shamique/neurosleep-demo) · [Kaggle](https://www.kaggle.com/shamiquekhan/neurosleep-final) · [Paper (coming soon)](#)
96
 
97
  A compact PyTorch model for five-stage sleep-stage classification from polysomnography signals. Processes 300 seconds of context (10 × 30-second epochs) and classifies each epoch into Wake, N1, N2, N3, or REM. Designed for edge deployment on resource-constrained devices.
98
 
@@ -177,29 +169,26 @@ Wake / N1 / N2 / N3 / REM
177
  | 3 | N3 | Deep sleep |
178
  | 4 | REM | Rapid eye movement sleep |
179
 
180
- ## Evaluation (15 subjects, 4-fold subject-level CV)
181
-
182
- > **Note:** Evaluation uses 4-fold subject-level cross-validation with 4 held-out test subjects (SC4001, SC4002, SC4011, SC4012). The other 11 subjects appear only in training.
183
 
184
  | Metric | Value |
185
  |--------|-------|
186
- | Accuracy | 93.0% ± 1.0% |
187
- | Cohen's Kappa | 0.861 ± 0.027 |
188
- | Macro F1 | 0.794 ± 0.036 |
189
- | Weighted F1 | 0.935 ± 0.007 |
190
- | Geometric Mean Recall | 0.816 ± 0.043 |
191
 
192
- ### Per-Class Performance
193
 
194
- | Stage | F1 | Precision | Recall | Support |
195
- |-------|-----|-----------|--------|---------|
196
- | Wake | 0.982 ± 0.010 | 0.997 | 0.968 | ~3,832 |
197
- | N1 | **0.455 ± 0.157** | 0.416 | 0.525 | ~116 |
198
- | N2 | 0.874 ± 0.044 | 0.916 | 0.841 | ~421 |
199
- | N3 | 0.856 ± 0.066 | 0.810 | 0.920 | ~446 |
200
- | REM | 0.803 ± 0.063 | 0.714 | 0.936 | ~441 |
201
 
202
- > **Honest assessment:** Overall accuracy (93%) is strong, but N1 recall is only 52.5% — the model frequently misclassifies N1 epochs as Wake or N2. This is expected given N1 is only 3.4% of the dataset. REM precision (71.4%) reflects physiological overlap with N2.
203
 
204
  ## Preprocessing
205
 
@@ -214,13 +203,14 @@ See the [source repo](https://github.com/shamiquekhan/neuromorphic-sleep-staging
214
 
215
  ## Training Details
216
 
217
- - **Dataset:** Sleep-EDF Expanded (15 subjects, PhysioNet)
218
- - **Optimizer:** AdamW (lr=3e-4, weight_decay=1e-2)
219
- - **Epochs:** 15
220
  - **Class weights:** N1=2x, REM=2x
221
  - **Supervision:** All-position (every epoch in 10-epoch window)
222
  - **Gradient clipping:** max_norm=1.0
223
- - **Class distribution:** Wake=68.8%, N1=3.4%, N2=16.4%, N3=5.0%, REM=6.4%
 
224
 
225
  ## LoRA Adaptation (Parameter-Efficient Fine-Tuning)
226
 
@@ -230,41 +220,39 @@ The model supports **LoRA (Low-Rank Adaptation)** for efficient fine-tuning on n
230
 
231
  | Property | Value |
232
  |----------|-------|
233
- | Target modules | `head` (classification layer) |
234
  | Rank | 8 |
235
  | Alpha | 16 |
236
  | Scaling | 2.0 |
237
- | Trainable params | 552 (0.55% of total) |
238
 
239
  ### Apply LoRA
240
 
241
  ```python
242
- from peft import LoraConfig, get_peft_model
243
-
244
- lora_config = LoraConfig(
245
- r=8,
246
- lora_alpha=16,
247
- target_modules=["head"],
248
- lora_dropout=0.05,
249
- bias="none",
250
  )
251
 
252
  model = ImprovedStudent()
253
  model.load_state_dict(load_file(ckpt_path, device="cpu"))
254
- model = get_peft_model(model, lora_config)
255
- model.print_trainable_parameters()
256
- # trainable params: 552 || all params: 99,477 || trainable%: 0.55%
257
  ```
258
 
259
- ### LoRA vs Full Fine-Tuning
260
 
261
  | Method | Trainable Params | Accuracy | Macro F1 |
262
  |--------|-----------------|----------|----------|
263
- | Frozen Base | 0 | 83.0% | 0.644 |
264
- | LoRA r=8 | 552 | 89.1% | 0.686 |
265
- | Full Fine-Tuning | 99,477 | 93.0% | 0.794 |
266
 
267
- LoRA achieves **94% of full fine-tuning accuracy** with **0.55% of the parameters**. See the [source repo](https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline) for LoRA training scripts.
268
 
269
  ## Intended Use
270
 
@@ -276,10 +264,10 @@ LoRA achieves **94% of full fine-tuning accuracy** with **0.55% of the parameter
276
  ## Limitations
277
 
278
  - **Not clinically validated** — do not use for diagnosis or clinical decision-making
279
- - N1 classification is challenging (F1=0.455) due to brief, transitional light sleep
280
- - Trained on Sleep-EDF Expanded (15 subjects); generalizability should be validated
281
  - Requires 4-channel PSG (Fpz-Cz, Pz-Oz, EOG, EMG) — single-channel EEG not supported
282
- - Class distribution is Wake-dominant (68.8%) from untrimmed recordings
283
 
284
  ## Resources
285
 
 
52
  name: Sleep Stage Classification
53
  dataset:
54
  type: sleep-edf-expanded
55
+ name: Sleep-EDF Expanded (92 subjects, PhysioNet)
56
  config: default
57
  split: test
58
  revision: main
59
  metrics:
60
  - type: accuracy
61
+ value: 0.877
62
  name: Accuracy
63
  verified: false
64
  - type: cohen_kappa
65
+ value: 0.763
66
  name: Cohen's Kappa
67
  verified: false
68
  - type: f1
69
+ value: 0.730
70
  name: Macro F1
71
  verified: false
72
  - type: f1
73
+ value: 0.890
74
  name: Weighted F1
75
  verified: false
 
 
 
 
 
 
 
 
76
  widget:
77
  - src: https://huggingface.co/spaces/shamique/neurosleep-demo
78
  title: NeuroSleep Live Demo
 
82
 
83
  # NeuroSleep — Light-Weight Sleep Stage Model
84
 
85
+ **99,477 parameters, 87.7% accuracy (κ=0.763) — small enough for edge/wearable deployment, scoring Wake/N1/N2/N3/REM from 4-channel PSG.**
86
 
87
+ > **Quick links:** [GitHub](https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline) · [Live Demo](https://huggingface.co/spaces/shamiquekhan/neurosleep-demo) · [Kaggle](https://www.kaggle.com/shamiquekhan/neurosleep-final)
88
 
89
  A compact PyTorch model for five-stage sleep-stage classification from polysomnography signals. Processes 300 seconds of context (10 × 30-second epochs) and classifies each epoch into Wake, N1, N2, N3, or REM. Designed for edge deployment on resource-constrained devices.
90
 
 
169
  | 3 | N3 | Deep sleep |
170
  | 4 | REM | Rapid eye movement sleep |
171
 
172
+ ## Evaluation (92 subjects, 10-fold subject-level CV, 3 seeds)
 
 
173
 
174
  | Metric | Value |
175
  |--------|-------|
176
+ | Accuracy | 87.7% ± 2.7% |
177
+ | Cohen's Kappa | 0.763 ± 0.043 |
178
+ | Macro F1 | 0.730 ± 0.037 |
179
+ | Weighted F1 | 89.0% ± 2.1% |
 
180
 
181
+ ### Per-Class Performance (Full Fine-Tuning)
182
 
183
+ | Stage | F1 | Precision | Recall |
184
+ |-------|-----|-----------|--------|
185
+ | Wake | 0.964 ± 0.016 | 0.995 | 0.936 |
186
+ | N1 | **0.445 ± 0.061** | 0.330 | 0.712 |
187
+ | N2 | 0.768 ± 0.041 | 0.878 | 0.687 |
188
+ | N3 | 0.681 ± 0.114 | 0.562 | 0.896 |
189
+ | REM | 0.771 ± 0.078 | 0.772 | 0.785 |
190
 
191
+ > **Honest assessment:** Overall accuracy (87.7%) is strong with balanced performance across all five stages. N1 is the most challenging stage (F1=0.445) due to its transitional nature and low prevalence (~4.6% of epochs).
192
 
193
  ## Preprocessing
194
 
 
203
 
204
  ## Training Details
205
 
206
+ - **Dataset:** Sleep-EDF Expanded (92 subjects, PhysioNet)
207
+ - **Optimizer:** AdamW (lr=3e-4, weight_decay=1e-4)
208
+ - **Epochs:** 20 (early stopping patience=5)
209
  - **Class weights:** N1=2x, REM=2x
210
  - **Supervision:** All-position (every epoch in 10-epoch window)
211
  - **Gradient clipping:** max_norm=1.0
212
+ - **Mixed precision:** True (CUDA)
213
+ - **Seeds:** 42, 43, 44 (30 folds per method)
214
 
215
  ## LoRA Adaptation (Parameter-Efficient Fine-Tuning)
216
 
 
220
 
221
  | Property | Value |
222
  |----------|-------|
223
+ | Target modules | `enc.0.pw`, `enc.1.pw`, `head` |
224
  | Rank | 8 |
225
  | Alpha | 16 |
226
  | Scaling | 2.0 |
227
+ | Trainable params | 1,448 (1.43% of total) |
228
 
229
  ### Apply LoRA
230
 
231
  ```python
232
+ from sleep_staging.adaptation.lora import LoRAConfig, apply_lora
233
+
234
+ lora_config = LoRAConfig(
235
+ rank=8,
236
+ alpha=16,
237
+ target_modules=["enc.0.pw", "enc.1.pw", "head"],
238
+ dropout=0.05,
 
239
  )
240
 
241
  model = ImprovedStudent()
242
  model.load_state_dict(load_file(ckpt_path, device="cpu"))
243
+ model = apply_lora(model, lora_config)
244
+ # trainable params: 1,448 || all params: 99,477 || trainable%: 1.43%
 
245
  ```
246
 
247
+ ### LoRA vs Full Fine-Tuning (100-Subject Benchmark)
248
 
249
  | Method | Trainable Params | Accuracy | Macro F1 |
250
  |--------|-----------------|----------|----------|
251
+ | Frozen Base | 0 | 87.1% | 0.673 |
252
+ | LoRA CNN+Head | 1,448 | 83.6% | 0.674 |
253
+ | **Full Fine-Tuning** | **99,477** | **87.7%** | **0.730** |
254
 
255
+ LoRA CNN+Head uses **68.7× fewer trainable parameters** while retaining **95.4% of full FT accuracy**.
256
 
257
  ## Intended Use
258
 
 
264
  ## Limitations
265
 
266
  - **Not clinically validated** — do not use for diagnosis or clinical decision-making
267
+ - N1 classification is challenging (F1=0.445) due to brief, transitional light sleep
268
+ - Trained on Sleep-EDF Expanded (92 subjects); generalizability should be validated
269
  - Requires 4-channel PSG (Fpz-Cz, Pz-Oz, EOG, EMG) — single-channel EEG not supported
270
+ - Class distribution is Wake-dominant (~68%) from untrimmed recordings
271
 
272
  ## Resources
273