Skip to content
September 09, 2020

Classification of hypoglycemia causes in blood sugar time series


  • Gustav Eklund
  • Amund Vedal


  • Gustav Eklund
  • Amund Vedal
  • Puya Sharif
  • Josef Lindman Hörnlund


Machine learning (ML) in the healthcare sector is an interesting area with a lot of important applications. In this post, we give an overview of a study conducted in collaboration with Daniel Espes and Per-Ola Carlsson at Uppsala University aiming to improve the treatment of type 1 diabetes. The primary aim was to predict the root cause of hypoglycemic events (i.e. periods of low blood glucose) using time series data consisting of Continuous Glucose Measurements (CGM).

Furthermore, interpreting how the deep learning model makes predictions based on the CGM time series alone could improve the scientific understanding of CGM classification and help clinicians understand the patients’ glucose measurements in a more refined way. Model interpretation is an active research area within ML and may be applied also to other clinical applications from a broader perspective. 

The team on Modulai’s side consisted of Gustav Eklund and Amund Vedal as machine learning engineers and Puya Sharif and Josef Lindman Hörnlund as project advisors.

This post might be updated in the future with results and performance metrics contingent on the submission and acceptance of the research paper.

Why is the identification of hypoglycemic root causes important?

Type 1 diabetes is one of the most common chronic disorders among children and adolescents but affects people of all ages and globally more than 5 million people are affected. In type 1 diabetes the insulin-producing beta-cells are lost due to an autoimmune attack and hence the ability to regulate blood glucose levels. The affected is therefore solely dependent on exogenous insulin treatment for regulating glucose in order to survive. Since there is a manual regulation of the insulin dosage, the blood sugar level may vary significantly depending on how meticulous the patient is with dosing, meal glucose estimations, and exercise. Despite intense efforts, it is nearly impossible to fully mimic normal glucose regulation due to its physiological complexity and the many external aspects that influence glucose levels. If too much insulin is administered, the glucose levels decrease to critically low levels, i.e. hypoglycemia which requires immediate attention and may be lethal if no action is taken. On the other hand, if the insulin dose is inadequate the inevitable mean increase in glucose levels dramatically increases the risk of long-term complications such as kidney failure, vision impairment, and cardiovascular disease. 

In general practice, most patients only see their diabetes nurse and doctor a few times per year. When reviewing the patients’ GCM-data, which can consist of up to 50 000 data points, time is limited and hence it is very difficult to scrutinize the data therefore most treatment adjustments are based on mean values and average trends. Hence, a lot of information is lost in translation, and therefore patients risk having unattended fundamental treatment problems with their insulin dosage for years without the proper adjustments.

Using ML for hypoglycemia root cause

Extensive work has been conducted in order to predict the likelihood of hypoglycemia with the intent to be used in real-time applications, i.e. hybrid- and closed-loop insulin pumps. This is of great value for the patient but does not help the clinician to assess necessary changes in the insulin treatment. However, in this project, the root cause of hypoglycemia was the main focus which in extension could serve as a decision support system in the clinical setting. 

Essentially, one may isolate a few major causes of hypoglycemia and they are of different value to a clinician. One cause could be too high basal insulin pressure. The basal insulin pressure is the result of the glucose-lowering effect from long-acting insulin administered once or twice daily or from the continuous basal infusion rate for patients who use an insulin pump. Another common cause of hypoglycemia is the overestimation of bolus insulin to a meal or overestimation of insulin doses administered with the intent to correct high glucose levels. As noted above, oftentimes there is too much data for a clinician to go through to make a well-grounded decision, and it would therefore be of great value if these causes could be automatically detected.  

For this project, CGM measurements for hypoglycemia events were labeled by clinical experts. The time series along with auxiliary information about the event were used to train various deep neural net configurations, with the aim of correctly classifying each hypoglycemic event. 

Experiments were also performed with pseudo-labeling, semi-supervised approaches, mitigating potential model prediction bias, and other alterations to produce a robust, unbiased model for the application. The results so far look very promising and we are now conducting more tests with an increased dataset after which we will disclose the method more in detail.

Model interpretability

An important part, especially in medical applications is making the system trustable and transparent. Deep learning interpretability is an active area of research. Aside from discovering apparent bugs or weaknesses in the classification process, model interpretability can further increase confidence in prediction by ensuring that the basis on which the model predicts is sensible. It can also offer further insights where a scientific understanding of decision boundaries is limited.

The figure shows an example of how the model can be interpreted. In the figure, the same hypoglycemia event has been evaluated against three of the root causes included in the study. Red areas are contributing positively to the model’s predicted likelihood of that certain root cause, blue areas the other way around. 

In this particular case, the first “bump” which most likely comes from a meal+bolus insulin event, is discriminative for classifying the hypoglycemia just after. Also, some points after the hypoglycemia event seem to have some impact on the classification.

Next steps

This project has given a lot of interesting insights into how ML can be used for continuous health data, and a range of potential continuations have been identified. The predictive accuracy of the models shows that deep learning has a clear potential for these applications. Leveraging both time series and tabular information will enable the use of more complex models and more accurate predictions. Also, weak labeling approaches of active labeling workflows may be explored as the cost of each label is high. 

The results are very promising and we are now expanding our work on validating the model so that it can be made available for patients and healthcare professionals as a tool to improve diabetes care. We are proud to be involved in this work to apply machine learning in new medical applications, and we are excited to continue this work in the future.

Wanna discuss AI for Medtech?