lebiraja commited on
Commit
cbf8655
·
verified ·
1 Parent(s): 09c98e5

Add model card (README.md)

Browse files
Files changed (1) hide show
  1. README.md +189 -0
README.md ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - eeg
5
+ - depression
6
+ - mental-health
7
+ - mdd
8
+ - biosignals
9
+ - ensemble
10
+ - pytorch
11
+ - xgboost
12
+ - svm
13
+ - neuroscience
14
+ datasets:
15
+ - figshare-eeg-depression
16
+ metrics:
17
+ - accuracy
18
+ - roc_auc
19
+ - f1
20
+ language: []
21
+ model-index:
22
+ - name: EEG Depression Detection V4
23
+ results:
24
+ - task:
25
+ type: classification
26
+ name: EEG-based MDD Detection
27
+ dataset:
28
+ name: Figshare EEG Depression (64 subjects, LOSO CV)
29
+ type: figshare-eeg-depression
30
+ metrics:
31
+ - type: accuracy
32
+ value: 0.9062
33
+ name: Subject Accuracy (threshold=0.5)
34
+ - type: accuracy
35
+ value: 0.9688
36
+ name: Subject Accuracy (threshold=0.575)
37
+ - type: roc_auc
38
+ value: 0.9980
39
+ name: AUC-ROC
40
+ - type: f1
41
+ value: 0.9714
42
+ name: F1 Score (threshold=0.575)
43
+ ---
44
+
45
+ # EEG-Based Depression (MDD) Detection — V4 Ensemble
46
+
47
+ **Leave-One-Subject-Out (LOSO) cross-validated EEG classifier for Major Depressive
48
+ Disorder, achieving 96.88 % subject-level accuracy and 99.80 % AUC-ROC on 64 subjects
49
+ from the public figshare EEG dataset.**
50
+
51
+ ---
52
+
53
+ ## Model Architecture
54
+
55
+ This is a **3-model heterogeneous ensemble**:
56
+
57
+ | Component | Details |
58
+ |-----------|---------|
59
+ | **1D-CNN** (weight=0.60) | Multi-scale convolution stem → 4 × ResBlock1D + SEBlock1D → GlobalAvgPool → MLP. Input: raw EEG (19 ch × 1000 samples). |
60
+ | **XGBoost** (weight=0.25) | 800 estimators, max_depth=6, trained on 1047-dim handcrafted features. |
61
+ | **SVM** (weight=0.15) | RBF kernel (C=10, γ=scale), trained on the same 1047-dim features. |
62
+
63
+ Epoch-level probabilities from each model are aggregated as a weighted sum, then
64
+ subject-level probability is the trimmed mean (5 % trim) of epoch probabilities.
65
+
66
+ ### Handcrafted Feature Set (1047 dimensions)
67
+
68
+ | Group | Dims | Description |
69
+ |-------|------|-------------|
70
+ | Spectral power | 95 | Band power per channel (δ/θ/α/β/γ) |
71
+ | Temporal stats | 171 | Mean, variance, skewness, kurtosis, Hjorth params, zero-crossing rate |
72
+ | Wavelet / WPD | 304 | Wavelet Packet Decomposition energy + entropy |
73
+ | Connectivity | 342 | Phase Locking Value + coherence between all channel pairs |
74
+ | Asymmetry | 40 | Frontal/temporal α asymmetry (8 electrode pairs) |
75
+ | Band ratios | 95 | Cross-band power ratios per channel |
76
+
77
+ ---
78
+
79
+ ## Performance (LOSO Cross-Validation, 64 subjects)
80
+
81
+ | Metric | Threshold=0.50 | Threshold=0.575 |
82
+ |--------|---------------|-----------------|
83
+ | Subject Accuracy | **90.62 %** (58/64) | **96.88 %** (62/64) |
84
+ | AUC-ROC | **99.80 %** | **99.80 %** |
85
+ | Sensitivity (MDD recall) | 100 % | 100 % |
86
+ | Specificity (Healthy recall) | 80.0 % | 93.3 % |
87
+ | F1 Score | 93.15 % | 97.14 % |
88
+
89
+ *Post-hoc threshold optimisation on LOSO predictions (threshold=0.575) yields 96.88 %
90
+ accuracy while maintaining 100 % sensitivity — no MDD subject is ever missed.*
91
+
92
+ ---
93
+
94
+ ## Dataset
95
+
96
+ - **Source**: [figshare EEG dataset](https://figshare.com/articles/dataset/EEG_Data_New/4244171)
97
+ - **Subjects**: 64 (34 MDD, 30 Healthy Controls)
98
+ - **EDF files**: 181
99
+ - **Channels**: 19 (standard 10-20 system)
100
+ - **Signal**: Bandpass 1–45 Hz, notch 50/60 Hz, resampled to 250 Hz
101
+ - **Epochs**: 4 s, 50 % overlap → ~570 epochs/subject on average
102
+ - **Total epochs**: 36,247
103
+
104
+ ---
105
+
106
+ ## Repository Files
107
+
108
+ ```
109
+ models/
110
+ final/
111
+ cnn_final.pt # CNN state dict (trained on all 64 subjects)
112
+ xgboost_final.json # XGBoost model (all 64 subjects)
113
+ svm_and_scaler_final.pkl # SVM + StandardScaler (all 64 subjects)
114
+ fold_NN_SID/ # One directory per LOSO fold (64 total)
115
+ cnn_weights.pt
116
+ xgboost.json
117
+ svm_and_scaler.pkl
118
+ checkpoints/
119
+ fold_NN_SID.pkl # Per-fold LOSO results (probs, labels, metrics)
120
+ config/
121
+ model_config.yaml
122
+ data_config.yaml
123
+ training_config.yaml
124
+ results_best.json # Full LOSO metrics from training
125
+ test_loso_results.json # Metrics from test_loso.py
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Usage
131
+
132
+ ### Load CNN
133
+
134
+ ```python
135
+ import torch
136
+ from eeg_depression_detection.models.full_model import EEG1DCNN # adjust import path
137
+
138
+ CNN_CONFIG = dict(
139
+ n_channels=19,
140
+ n_samples=1000,
141
+ n_classes=2,
142
+ )
143
+ model = EEG1DCNN(**CNN_CONFIG)
144
+ state = torch.load("models/final/cnn_final.pt", map_location="cpu")
145
+ model.load_state_dict(state)
146
+ model.eval()
147
+ ```
148
+
149
+ ### Load XGBoost
150
+
151
+ ```python
152
+ import xgboost as xgb
153
+ xgb_model = xgb.XGBClassifier()
154
+ xgb_model.load_model("models/final/xgboost_final.json")
155
+ ```
156
+
157
+ ### Load SVM + Scaler
158
+
159
+ ```python
160
+ import pickle
161
+ with open("models/final/svm_and_scaler_final.pkl", "rb") as f:
162
+ bundle = pickle.load(f)
163
+ svm_model = bundle["svm"]
164
+ scaler = bundle["scaler"]
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Citation
170
+
171
+ If you use this model or dataset pipeline in your research, please cite:
172
+
173
+ ```bibtex
174
+ @misc{eeg_depression_v4,
175
+ author = {Pranav},
176
+ title = {EEG Depression Detection V4 Ensemble},
177
+ year = {2026},
178
+ publisher = {HuggingFace},
179
+ howpublished = {\url{https://huggingface.co/lebiraja/eeg-depression-v4}},
180
+ }
181
+ ```
182
+
183
+ ---
184
+
185
+ ## Licence
186
+
187
+ MIT — see [LICENSE](https://github.com/pranov888/eeg-depression/blob/main/LICENSE)
188
+
189
+ *Generated 2026-03-11*