--- title: Sundew Diabetes Commons sdk: docker colorFrom: green colorTo: blue pinned: true emoji: 🌿 license: mit --- # 🌿 Sundew Diabetes Watch β€” Advanced Edition **Mission:** Deliver low-cost, energy-aware diabetes risk monitoring for everyone β€” with a special focus on communities across Africa. This app demonstrates the **full capabilities of Sundew’s bio-inspired adaptive algorithms**, including: - ✨ **PipelineRuntime** with a custom `DiabetesSignificanceModel` - πŸ“Š **Real-time energy tracking** with bio-inspired regeneration - 🎯 **PI-control threshold adaptation** with live visualization - πŸ“ˆ **Bootstrap confidence intervals** for statistical validation - πŸ”¬ **Six-factor diabetes risk** computation (glycemic deviation, velocity, IOB, COB, activity, variability) - πŸ€– **Ensemble model** (LogReg + RandomForest + GBM) - πŸ’Ύ **Telemetry export** for hardware validation workflows - 🌍 **89.8% energy savings** versus always-on inference (validated on real CGM data) ## βœ… Proven Results Tested on 216 continuous glucose monitoring events (β‰ˆ18 hours): - **Activation rate:** 10.2% (22/216 events) β€” intelligently selective - **Energy savings:** 89.8% β€” essential for battery-powered wearables - **Risk detection:** Correctly identifies hypoglycemia (<70 mg/dL) and hyperglycemia (>180 mg/dL) - **Adaptive thresholds:** PI controller dynamically adjusts from 0.10 β†’ 0.95 based on glucose patterns ## πŸš€ Quick Start 1. **Try the demo:** [Sundew Diabetes Watch](https://huggingface.co/spaces/mgbam/sundew_diabetes_watch) 2. **Upload data:** Use your CSV or the [sample_diabetes_data.csv](https://huggingface.co/spaces/mgbam/sundew_diabetes_watch/blob/main/sample_diabetes_data.csv) 3. **Observe:** Real-time significance scoring, threshold adaptation, and energy tracking 4. **Experiment:** Tweak Energy Pressure, Gate Temperature, and presets ## πŸ› οΈ How It Works 1. **Upload CGM data** with columns: `timestamp, glucose_mgdl, carbs_g, insulin_units, steps, hr` 2. **Custom significance model** computes a multi-factor diabetes risk score 3. **Sundew gating** decides when to run the heavy ensemble model 4. **PI control** auto-adjusts thresholds to maintain target activation 5. **Energy management** uses bio-inspired regeneration and realistic costs 6. **Statistical validation** via bootstrap 95% CIs (F1, Precision, Recall) 7. **Telemetry export** (JSON) for power-measurement correlation ## πŸ“Ί Live Visualizations - **Glucose levels:** Continuous CGM stream - **Significance vs. threshold:** See the PI controller adapt in real time - **Energy level:** Bio-inspired regeneration over time - **Risk components (Γ—6):** Interpretable breakdown of the score - **Performance dashboard:** F1, Precision, Recall with confidence intervals - **Alerts:** High-risk notifications ## πŸ”§ Configuration Presets - **custom_health_hd82:** Healthcare-optimized (β‰ˆ82% energy savings, ~0.196 recall) - **tuned_v2:** Balanced general-purpose baseline - **auto_tuned:** Dataset-adaptive configuration - **conservative:** Maximum savings (lower activation) - **energy_saver:** Battery-optimized for edge devices > **Disclaimer:** Research prototype. Not medical advice. Not FDA/CE approved. ## πŸ’» Developing Locally ```bash python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt streamlit run app_advanced.py 🧠 Technical Details Algorithm: Sundew bio-inspired adaptive gating Model: Ensemble (LogReg + RandomForest + GBM) Risk factors: Six-component diabetes-specific significance model Control: PI threshold adaptation with energy-pressure feedback Energy model: Random regeneration (1.0–3.0 per tick) + realistic costs Validation: Bootstrap resampling (1,000 iterations) for 95% CI πŸ“š References Sundew Algorithms Documentation Paper (coming soon) Built with ❀️ for underserved communities worldwide.