|
Download docs/ML_summary.md from Laibaff7/cda-emr-classifier: direct link, hf CLI and curl.
- Browser
- Download file 3.74 kB
-
https://huggingface.co/Laibaff7/cda-emr-classifier/resolve/main/docs/ML_summary.md
- Command line
-
hf download hf://Laibaff7/cda-emr-classifier/docs/ML_summary.md
-
curl -L -o ML_summary.md https://huggingface.co/Laibaff7/cda-emr-classifier/resolve/main/docs/ML_summary.md
3.74 kB
| # EMR Classifier β Summary | |
| Binary classifier that flags **Extended Mass Range (EMR)** events in Cassini CDA TOF | |
| mass spectra, then ranks the full unlabelled pool by EMR-likeness. | |
| ## Objective | |
| Distinguish the **34 known EMR spectra** (class 1) from unlabelled background spectra | |
| (class 0) in the high-mass region, and use the model to rank **130,233** unlabelled | |
| spectra as a triage list of EMR candidates. | |
| ## Data | |
| | Set | Source | Size | | |
| |-----|--------|------| | |
| | Positives | `training data for extended mass range.parquet` | 34 spectra | | |
| | Negative pool | `Data Parquet/unknown_data_after_noise_filter_cropped.parquet` | 130,233 spectra | | |
| - Input feature: spectrum cropped to **channels 700β1017** (318 channels), the model region. | |
| - Preprocessing: **per-spectrum min-max normalisation** to [0, 1] (the only transform). | |
| - 1,000 negatives are subsampled from the pool for training (fixed `DATA_SEED=42`). | |
| ## Model | |
| Shallow 1D CNN (same architecture as the HMOC classifier), chosen to limit overfitting | |
| on only 34 positives: | |
| ``` | |
| Conv1d(1β32, k7) β BN β ReLU | |
| Conv1d(32β64, k5) β BN β ReLU | |
| Conv1d(64β128, k3) β BN β ReLU | |
| AdaptiveAvgPool1d(1) | |
| Linear(128β64) β ReLU β Dropout(0.4) β Linear(64β1) β sigmoid | |
| ``` | |
| ## Handling class imbalance (34 pos : 1000 neg β 1:30) | |
| - **Focal Loss** (Ξ± = 0.85, Ξ³ = 2.0) | |
| - **WeightedRandomSampler** (inverse class frequency) | |
| - Shallow CNN + dropout | |
| - **5-seed ensemble** (one model per stratified 5-fold) for robustness | |
| ## Training setup | |
| - Stratified 5-fold CV; seeds `[42, 100, 2026, 777, 888]` | |
| - AdamW, lr = 1e-3, weight_decay = 1e-4; batch size 64 | |
| - Max 100 epochs, early stopping (patience 15) on validation AUPRC | |
| - Best-F1 threshold scanned per fold | |
| ## Validation results (per fold) | |
| | Seed | AUPRC | Precision | Recall | F1 | Best thr | | |
| |------|-------|-----------|--------|------|----------| | |
| | 42 | 0.938 | 1.000 | 0.857 | 0.923 | 0.75 | | |
| | 100 | 1.000 | 0.875 | 1.000 | 0.933 | 0.60 | | |
| | 2026 | 0.860 | 0.857 | 0.857 | 0.857 | 0.50 | | |
| | 777 | 0.981 | 1.000 | 0.714 | 0.833 | 0.80 | | |
| | 888 | 0.878 | 0.545 | 1.000 | 0.706 | 0.75 | | |
| ## Inference (5-model ensemble mean over all 130,233 spectra) | |
| - Probability distribution: mean 0.0457, p50 0.0015, p99 0.6915, max 0.9025 | |
| - Candidates: **4,837** β₯ 0.5 Β· **749** β₯ 0.75 Β· **1** β₯ 0.9 | |
| - Top candidate: sclk `1561703929` (prob 0.9025) | |
| - Full ranked list: `predictions/emr_candidates_unknown.csv` Β· top 100: `predictions/emr_top100.csv` | |
| ## Data-leakage audit (clean) | |
| - Positive SCLK overlap with the inference pool: **0** (no positive leakage) | |
| - Top-100 candidates that were also training negatives: **0 / 100** | |
| - Training-negative mean probability (0.0427) β other rows (0.0458) β no anomalous scoring | |
| - Report: `predictions/leakage_report.json` | |
| ## Files | |
| ``` | |
| EMR Classifier/ | |
| code/ | |
| crop_unknown_data.py # add spectrum_cropped (700-1017) to the unknown pool | |
| train_emr_classifier.py # 5-seed 5-fold training (Spectra1DCNN + FocalLoss) | |
| infer_unknown.py # ensemble inference over the 130k pool | |
| check_leakage.py # leakage audit | |
| models/ | |
| emr_model_seed_{42,100,2026,777,888}.pth | |
| metrics.json | |
| predictions/ | |
| emr_candidates_unknown.csv # all 130,233 ranked | |
| emr_top100.csv | |
| leakage_report.json | |
| top100_spectrum_viewer.ipynb # interactive browser for the top-100 candidates | |
| ``` | |
| ## Caveats | |
| - Trained on only **34 positives** β this is a **ranked triage list**, not a definitive | |
| classifier. Validate top candidates before treating them as confirmed EMR events. | |
| - Negative subsample is fixed (`DATA_SEED=42`); results are reproducible. | |
| - Run training/inference with the `ml_env` conda environment (torch, sklearn, pandas, pyarrow). |