File size: 3,985 Bytes
ba81f60
 
 
 
 
 
 
 
 
c34ce9a
ba81f60
c34ce9a
ba81f60
c34ce9a
 
 
ba81f60
c34ce9a
ba81f60
c34ce9a
ba81f60
 
c34ce9a
ba81f60
 
 
c34ce9a
 
 
 
 
 
ba81f60
 
 
c34ce9a
 
 
 
ba81f60
c34ce9a
ba81f60
c34ce9a
 
 
 
 
 
 
ba81f60
c34ce9a
ba81f60
c34ce9a
 
 
 
 
 
ba81f60
c34ce9a
ba81f60
c34ce9a
 
 
 
 
ba81f60
 
 
c34ce9a
ba81f60
 
 
 
 
c34ce9a
 
 
 
 
 
 
 
 
 
ba81f60
c34ce9a
ba81f60
c34ce9a
 
ba81f60
c34ce9a
ba81f60
c34ce9a
ba81f60
c34ce9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
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.