开发者用个人数据训练 15 个血糖预测模型
一位 1 型糖尿病开发者开源 T1DMAI 项目,在个人数据与公开 MetaboNet 数据集上训练并对比了 15 个血糖预测模型。其自研的 D16 小型 Transformer 可提前 2 小时预测血糖,采用 DILATE 与 MSE 两种损失函数,先以合成轨迹预训练再叠加 LoRA 适配器微调。项目还横向评测了 LSTM、Chronos-2、TimesFM 2.5 等基线模型。
报道正文
本文目录2 个章节
T1DMAI
[!NOTE] Most of the code in this repo was written by AI. If you don't like that, feel free to leave.
This repo is a zoo. Here I train & test many blood glucose forecasting models (including my own) on both my own data and metabonet (public).
My model is a small transformer that forecasts blood glucose 2 hours ahead. I've made two variants: D16 DILATE and D16 MSE which use DILATE and MSE loss for training, respectively. D16 refers to the width of the model (16). They are both trained on synthetic traces, and then a LoRA adapter is added for light fine-tuning, but I also test them without the adapter.
Feast thine eyes on some of their forecasts (these have been trained on synthetic traces, then fine-tuned with a LoRA adapter on my training split):
<picture> <source media="(prefers-color-scheme: dark)" srcset="screenshots/personal-days-d16-dilate-1-dark.png"> <img alt="T1DMAI D16 DILATE forecasting my glucose, test days block 1" src="screenshots/personal-days-d16-dilate-1.png"> </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="screenshots/personal-days-d16-dilate-2-dark.png"> <img alt="T1DMAI D16 DILATE forecasting my glucose, test days block 2" src="screenshots/personal-days-d16-dilate-2.png"> </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="screenshots/personal-days-d16-rmse-1-dark.png"> <img alt="T1DMAI D16 MSE forecasting my glucose, test days block 1" src="screenshots/personal-days-d16-rmse-1.png"> </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="screenshots/personal-days-d16-rmse-2-dark.png"> <img alt="T1DMAI D16 MSE forecasting my glucose, test days block 2" src="screenshots/personal-days-d16-rmse-2.png"> </picture>[!CAUTION] Research and educational use only - not a medical device. T1DMAI is a research artifact. It is not clinically validated, has no regulatory clearance, and its output is a forecast of research signals, not medical advice. It must not be used to make medical, diagnostic, or treatment decisions, to calculate or adjust insulin doses, or to manage diabetes in any way. For medical guidance consult a qualified healthcare professional. The software is provided "as is", without warranty of any kind (see LICENSE).
1. Background
I have type 1 diabetes and I wanna know if I can train a BG forecasting model to help me with my daily management. To this end I've made some auxiliary tools:
- T1DMSIM creates synthetic CGM traces since UVA/Padova was too slow on my laptop.
- T1DMDROID runs the models on my phone, also has some neat functionality like reading BG from multiple CGMs at once.
For evaluation, I use the recommendations by Jacobs et al., IEEE Reviews in Biomedical Engineering, 2024 [1]. It's a nice paper that you should probably read.
2. Main results
All models suck. XGBoost is the best one but my own model comes close. More details below:
- On my data, D16 DILATE + LoRA comes 3rd of 26 (22.8), behind XGBoost (22.2) and LightGBM (22.4). Wilcoxon puts it level with both at 60 and 90 min, behind them at 30 and 120.
- On MetaboNet, D16 DILATE + LoRA comes 9th (34.6) but has the lowest RMSE of all models at 90 min. XGBoost leads at 30, 60 and 120.
- At 60 min a 3771 parameter LoRA adapter helps both models on both datasets: 26.1 to 22.8 and 27.1 to 23.5 on my data, 36.6 to 34.6 and 36.7 to 35.1 on MetaboNet. At 120 min on MetaboNet it makes D16 DILATE worse (48.0 to 50.4).
- On MetaboNet, LoRA also fixes the bands. The 90% band holds the truth 75-78% of the time at 60 min with sim only and 81-85% with LoRA. On my data both are 83-85%.
- T1DMAI + LoRA reacts earliest on my data: 40-50 min time gain at 60 min, against 30 for XGBoost.
- It also catches the most lows on my data: 40-47% at 60 min, against 29% for XGBoost. On MetaboNet every low-RMSE model misses nearly all lows (XGBoost 0%, T1DMAI 6-8%), while linear extrapolation catches 58%.
- LightGBM matches XGBoost within 0.2 mg/dL everywhere. An LSTM with 15 hours of history comes 3rd on MetaboNet (33.6 at 60 min), against 35.9 for the 2 hour one.
- Zero-shot Chronos-2 and TimesFM 2.5 beat zero-shot Chronos-Bolt by 1.4-2.7 mg/dL at 60 min on both datasets, but trail fine-tuned Chronos-Bolt.
(注:更多技术实现细节与完整 API 文档请查阅原项目 README)