Objective mood-episode risk from your Apple Watch β clinically informed, privacy-first, open-source.
The clinical problem: No objective tool exists for predicting mood episodes or distinguishing unipolar from bipolar depression or borderline personality disorder. Clinicians rely on subjective recall; patients often seek help after crises begin.
Big Mood Detector analyzes your Apple Health data to predict mood episode risk using AI. Two complementary models:
- PAT transformer screens for current depression.
- XGBoost predicts tomorrow's depression/mania/hypomania risk.
When used together (--ensemble), see how your mood state evolves from today to tomorrow.
Built by a clinical psychiatrist, implementing published research. Runs 100% on-device, no cloud, no signup.
Current status: Research prototype β the first of its kind, but not yet clinically validated.
Our breakthrough:
- Early detection: Spot mood episode risk before symptoms spiral
- Two applications: Current depression screening (PAT) + next-day episode prediction (XGBoost)
- Objective data: Complement clinical assessment with continuous behavioral biomarkers
- Research foundation: First implementation combining two breakthrough papers:
- PAT: Dartmouth Foundation Model (arXiv)
- XGBoost: Nature Digital Medicine 2024 (GitHub)
- Privacy-first: Runs entirely on your device β your data never leaves your machine
For researchers: Validate these approaches across populations, build the evidence base for digital mental health. See PAT model training details for replication.
Consistent environment with all dependencies
# 1. Create security credentials
cat > .env << EOF
SECRET_KEY=$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')
API_KEY_SALT=$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')
EOF
# 2. Start services
docker-compose up -d api redis
# 3. Export Apple Health data (Settings β Health β Export)
# Place export.xml in: data/input/apple_export/
# 4. Analyze your data
docker run --rm \
-e BIGMOOD_DATA_DIR=/app/data \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/model_weights:/app/model_weights:ro" \
big-mood-detector:latest \
predict /app/data/input/apple_export/export.xml --reportRequires Python 3.12+
# 1. Install (numpy first to avoid conflicts)
pip install 'numpy<2.0'
pip install big-mood-detector
# 2. Export Apple Health data (Settings β Health β Export)
# Place export.xml in: data/input/apple_export/
# 3. For large files (>100MB), scan first to check data availability
big-mood predict data/input/apple_export/export.xml --scan
# 4. Analyze your data (research purposes)
big-mood predict data/input/apple_export/export.xml --report
# 5. With temporal analysis (NOW vs TOMORROW)
big-mood predict data/input/apple_export/export.xml --ensemble --report
# 6. Auto-window selection (enabled by default in v0.5.6+)
# Automatically finds optimal data windows for both models
big-mood predict data/input/apple_export/export.xml --report
# 7. To disable auto-window and specify dates manually
big-mood predict data/input/apple_export/export.xml --no-auto-window --date-range 2024-01-01:2024-03-31See full output in data/output/clinical_report.txt
Need model weights? Please contact me for a convenient Google Drive link containing:
- Pre-trained PAT transformer weights
- Fine-tuned depression detection head
- XGBoost model files
- Sample data for testing
This ensures you can run the application immediately without training models from scratch.
Your Apple Health Data
β
βββββββββββββββββββββββ
β Past 7 Days β β PAT (transformer) analyzes activity patterns
βββββββββββββββββββββββ€
β Past 30 Days β β XGBoost models circadian rhythms
βββββββββββββββββββββββ
β
Research Risk Scores (Not Diagnostic)
PAT = transformer AI, XGBoost = gradient boosting, ensemble = enhanced reliability.
New! Fast data scanning to preview what's available before processing:
# Scan a large export (takes seconds, not minutes)
big-mood predict export.xml --scan
# Example output:
π Data Summary:
β’ Total records: 8,755,251
β’ Heart Rate: 5,074,424 records
β’ Step Count: 3,513,756 records
β’ Sleep Analysis: 3,608 records
β
Available Features:
β’ depression_risk: Depression risk prediction (XGBoost)
β’ mania_risk: Mania/hypomania risk prediction (XGBoost)
β οΈ Unavailable Features:
β’ hrv_analysis: Missing required type: HKQuantityTypeIdentifierHeartRateVariabilitySDNNFiles over 100MB will automatically prompt to scan first. This prevents waiting 10+ minutes only to discover missing data.
| Component | Status | Performance |
|---|---|---|
| Apple Health XML parsing | β | 33MB/s, <100MB RAM |
| XML data scanning | β | 12s for 545MB file |
| PAT transformer model | β | 0.593 AUC depression (NHANES) |
| XGBoost circadian model | β | 0.80-0.98 AUC (Korean cohort) |
| Privacy-first processing | β | 100% local, no data sharing |
| Clinical feature extraction | β | DSM-5 aligned thresholds |
| REST API | β | Real-time predictions |
Processing Speed:
- 365 days of data: 17 seconds
- Memory usage: <100MB for any file size
- Parsing throughput: 33MB/s
Model Accuracy (from original research):
- Current depression screening (PAT, general population):
- Depression detection: 0.593 AUC (US NHANES 2013-14)ΒΉ
- Next-day episode prediction (XGBoost, mood disorder patients):
- Depression episodes: 0.80 AUC (Korean cohort, MDD+BD patients)Β²
- Manic episodes: 0.98 AUC (Korean cohort, BD patients)Β²
- Hypomanic episodes: 0.95 AUC (Korean cohort, BD patients)Β²
ΒΉRuan et al., 2024 | Β²Lim et al., 2024
-
Clinical innovation: First open-source tool combining two state-of-the-art approaches to predict mood episodes from wearable data
-
Scientific rigor: Faithful implementation of published algorithms:
- XGBoost circadian model from Seoul National University (Nature Digital Medicine 2024)
- PAT transformer from Dartmouth (first foundation model for actigraphy)
-
Privacy breakthrough: No cloud dependency, no data collection β your mental health data stays private
-
Intelligent data handling: Auto-window selection (v0.5.6+) automatically finds optimal analysis periods:
- Handles sparse Apple Watch data (gaps are OK for XGBoost)
- Prioritizes overlapping windows where both models can run
- Clear feedback on data availability and model selection
-
Open research: Complete transparency enables validation, improvement, and trust
Population specificity:
- XGBoost: Trained on 168 Korean adults (18-35y) with mood disorders
- PAT: Pre-trained on 21,538 US adults, fine-tuned on 2,800 with PHQ-9 scores
Performance constraints:
- Current depression screening: Moderate accuracy (0.593 AUC)
- Next-day episode prediction: High accuracy but limited to Korean cohort (0.80-0.98 AUC)
- No validation across ethnicities, age groups, or comorbid conditions
- Research tool only β not FDA approved or clinically validated
| Audience | Start Here |
|---|---|
| Users | Quick Start Guide |
| Developers | Architecture Overview |
| Researchers | Clinical Requirements β’ PAT Training Details |
| AI Assistants | CLAUDE.md |
Critical research needs:
- π₯ Clinical validation across diverse populations
- π Multi-ethnic, multi-age cohort studies
- π± Integration with additional wearable devices
- π§ͺ Improving transformer model accuracy
See CONTRIBUTING.md for guidelines.
Apache 2.0 - Use freely, even commercially. See LICENSE.
Built on pioneering research:
- XGBoost models: Seoul National University, Korea University, KAIST (Lim et al., 2024)
- PAT foundation model: Dartmouth College (Ruan et al., 2024)
Have feedback? Open an issue or see discussions.