News for hackers. Stuff that matters.
Re:Taking my diabetes treatment into my own hands (2024) by Mathnerd314 on Wednesday July 24, 2024 @12:05AM (#41053521)
> https://github.com/SmartCGMS/core/blob/dffdd89a274144d0e9ecb...

> Especially, a diabetic patient is warned that unauthorized use of this software may result into severe injury, including death.

I like the idea of the post - I have actually been thinking about including some biophysical models for medications in my app - but I do think that if you don't understand what a system of differential equations is, maybe trying to use a software library as a black box is a bad idea. For example... genetic algorithms... really? Like use a shooting method or bisection or something. If you have 3 doses you have 3 variables and it is all continuous so searching the space of inputs should be much easier than examining 51^4 discrete possibilities.

Re:Taking my diabetes treatment into my own hands (2024) by bigiain on Wednesday July 24, 2024 @01:34AM (#41053899)
> but I do think that if you don't understand what a system of differential equations is, maybe trying to use a software library as a black box is a bad idea.

<looks at all the AI hype>

Seems it's just you and me that think that way...

Re:Taking my diabetes treatment into my own hands (2024) by mjaniczek on Wednesday July 24, 2024 @02:42AM (#41054215)
Don't worry, I'm not using the app's suggestions blindly (or at all, currently). But yeah the SmartCGMS authors disclaimed as much - you're using it on your own risk.

This is probably also why apps like LibreLink don't provide predictions but only show historical data - easier to not get sued if you don't give the user advice that could kill them?

Re models, differential equations and finding minima: I do agree genetic algo is a bit wonky, and the greedy random walk at the bottom was able to get similar results. Do you have some resources for optimizing a N_51 x N_51 x N_51 x N_51 -> R+ unknown black-box function? My googling led me to eg. Metropolis-Hastings algorithm, but I don't currently get it (the translation to the probability domain escapes me). You're mentioning shooting method and bisection, I'll take a look at those.

Re:Taking my diabetes treatment into my own hands (2024) by nerdponx on Wednesday July 24, 2024 @05:29AM (#41055180)
> Do you have some resources for optimizing a N_51 x N_51 x N_51 x N_51 -> R+ unknown black-box function?

Maybe Bayesian optimization? That's often how hyperparameter optimization is done in machine learning, but that has the additional constraint that each computation of the loss function is very expensive.

In general the term "black-box optimization" is the right search term, or "derivative-free optimization" which is what Wikipedia calls it.

Re:Taking my diabetes treatment into my own hands (2024) by Mathnerd314 on Wednesday July 24, 2024 @10:37AM (#41057560)
So Metropolis-Hastings for example is a probabilistic algorithm. You don't need a probabilistic algorithm. (Well, you do when you want to estimate your physiological parameters, the Bayesian stuff and so on, but that is a whole separate can of worms). I didn't look too carefully at your objective function but it looked continuous - small perturbations in input mean small changes in the objective function. Like hypoglycemic readings, you can easily calculate "how hypoglyemic" rather than a yes/no. Naturally there are places where the objective function isn't continuous and that's where you have to do a discrete-style search, but when it's mostly continuous there are well-known numerical methods. Like check out https://docs.scipy.org/doc/scipy/reference/optimize.html, it isn't necessarily what you need but looking up the Wikipedia pages of the method names will be helpful. I've also found ChatGPT knows an insane amount of math, I wouldn't trust it to write a specific algorithm but it can give intelligent comparisons and list similar algorithms.

What I was saying is I don't think N_51 is the right way to model a dose. I would model it as a real number in the interval [0,50]. I would still round whatever the model gave to what I could actually measure out decently, but within the model I would not use discrete numbers.

Re:Taking my diabetes treatment into my own hands (2024) by Mathnerd314 on Wednesday July 24, 2024 @01:33PM (#41059553)
Oh and regarding probabilistic stuff, I have been playing with PyMC, it seems eminently usable. There is some slightly more specialized software like Stan, and it is certainly worth looking at some Stan tutorials if you don't know anything about probabilistic programming, but PyMC is hackable and modular in a way that Stan is not. There is also tensorflow-probability but I couldn't get it to work, it seems not as active as PyMC. Haven't read it but I found https://github.com/CamDavidsonPilon/Probabilistic-Programmin... and that's probably going to be my coffee table reading for the next few days.
Re:Taking my diabetes treatment into my own hands (2024) by derlvative on Wednesday July 24, 2024 @06:54AM (#41055622)
Don't worry, his doctor doesn't know what a differential equation is either so this is a large improvement.