Hacker News new | ask | show | jobs
Show HN: I have trained a model to predict my blood sugar (github.com)
6 points by 0xdeadf1sh 17 days ago
I have trained a custom 31,253 parameter encoder-only transformer on a pregenerated synthetic CGM dataset and fitted it to my own personal data using LoRA. It is competitive among other published models. I used 115 days of CGM data, of which 80 was used for training the adapter and 35 for testing. The model began with a pretraining stage where it consumed ~19,200 CGM-years worth of synthetic data, consisting of 1 million simulated type 1 diabetics at 7 days each. The simulator is designed to aid in counterfactual reasoning, but I don't yet have a benchmark to test these capabilities downstream. Simply using these models on my phone gives me the impression that they do indeed react appropriately when forced to consider future insulin & carbs.

In addition to time series input, two additional inputs are provided: insulin (U) and carbs (G, GI) as action curves where U = units of insulin, G = carbs in grams, GI = glycemic index. U is exact, while (G, GI) is my best estimate.

The model is trained to output BG in Kovatchev risk-space using {DILATE,MSE} and pinball loss combined with learned Kendall-Gal weights. The figures above show models trained using DILATE. It can predict 2 hours into the future, infill missing traces, and do backcasts (predictions into the past).

The model is also trained to predict time-of-day given past blood sugar, in contrast to other models that consume time-of-day as input feature. This capability emerges in >=48h context windows (i.e. 48 hours of past CGM trace). Natively the model has a variable context window size of 3.5 - 7.0 days.

The model is still worse than me when it comes to predicting hypoglycemia in the next ~30 minutes.

1 comments

I wrote a website that helped my wife's grandfather manage his diabetes. It was essentially captured that moment in time his blood sugar, blood pressure, and weight. This was 10 years ago, and his doctor loved it because he could generate a report and bring it to his visits.

What you're doing here is far beyond what I did and it's stuff like this that really make me white-pilled on the future. I know you said that the model is worse than you, but just think about how far stuff like this has come and what it might look like in the future.

Yeah all models are weirdly much worse at predicting hypos than hypers. I'd say the models are better than me when it comes to predicting hypers. Could be a data leak in my brain, but I'm not sure. There are neurons in the brain that sense falling blood sugar [1], so it is likely that I have access to some info that these models don't, albeit unconsciously.

[1] https://pmc.ncbi.nlm.nih.gov/articles/PMC10450823/

"Listen to your body" and "trust your gut" aren't always platitudes, it wouldn't surprise me if you can unconsciously sense when it's hitting (or about to hit).
Yeah I definitely "feel" it when a hypo is coming. At some point improving the accuracy of these models will likely involve a BCI.