Comments (3)
Thanks for raising this issue.
The simple add-up comes from the original UVa/Padova Simulator, but I agree that your proposed weighted average makes more sense, and it will bring the final risk index into the same scale of LBGI and HBGI. If you are interested, feel free to submit a PR to the repo, otherwise, I will do that.
FYI, there is a related risk index computation error reported here #62, which is due to the numpy version compatibility, and there is already a PR to fix this computation error.
from simglucose.
This is a follow up to my previous solution. It still suffers from a problem: the risk values are not capped to [0, 100] as they should be. This stems from the assumption in the paper that the bg values should be within [20, 600] mg/dL. Outside of that range we cannot depend on natural log to behave.
Here is the updated implementation - this should directly replace the contents of risk.py
:
import numpy as np
def risk_index(BG, horizon):
# BG is in mg/dL
BG_to_compute = BG[-horizon:]
risks =[risk(r) for r in BG_to_compute]
LBGI = np.mean([r[0] for r in risks])
HBGI = np.mean([r[1] for r in risks])
RI = np.mean([r[2] for r in risks])
return (LBGI, HBGI, RI)
def risk(BG):
MIN_BG = 20.0
MAX_BG = 600.0
if BG <= MIN_BG:
return (100.0, 0.0, 100.0)
if BG >= MAX_BG:
return (0.0, 100.0, 100.0)
U = 1.509 * (np.log(BG)**1.084 - 5.381)
ri = 10 * U**2
rl, rh = 0.0, 0.0
if U <= 0:
rl = ri
if U >= 0:
rh = ri
return (rl, rh, ri)
from simglucose.
Opened a PR with the proposed changes. Closed the old PR.
from simglucose.
Related Issues (20)
- The reward function encourages short episodes HOT 2
- Units in the Meal Absoption Model HOT 6
- Report function does not work HOT 2
- Controller is not reset during simulation of patients HOT 5
- Scenario with no meal in gym env HOT 2
- How to correctly implement the use of OpenAI Gym - reset() and step() methods are not implemented (NotImplementedError on google Colab)
- Dbar Modification HOT 3
- whether there is paper related to this project or not?
- Input meal size given in (g/min) instead of expected (g)
- Import Error
- Risk index calculation error in report generation
- Does this simulator has the property of time-delay? HOT 1
- Insulin unit error and scenario setting error HOT 3
- pip 0.2.8 broken HOT 2
- Patient interface missing observation, state and t HOT 2
- Clarity on calculation of parameters apha and beta HOT 2
- Patient Parameter Documentation
- Sensor sample_time affects reported CHO and Insulin
- Deprecated distutils in Python v3.12 causes "no module..." exception
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simglucose.