1. Introduction
Type 1 diabetes is among the most frequent chronic diseases in children and young people, having an important social and health impact and directly affecting the quality of life of the people who suffer from it. The disease begins when the pancreas does not produce enough insulin which results in an increase in the level of glucose in the blood stream and can cause heart and kidney problems or damage some of the nerves in the body. Despite the latest advances, an exact mechanism for treating the disease is not known. This increases the importance of proposing and validating techniques that facilitate the monitoring and treatment of type 1 diabetics [
1] and even the development of systems that allow the identification of patterns that can help finding the best treatment for each patient. Machine learning techniques and algorithms are proving to be able to build a solid foundation in many areas in general and for blood glucose prediction in particular [
2,
3]. The use of data from real patients combined with machine learning techniques and prediction algorithms allows us to monitor patients, predict possible drops or rises in blood glucose levels, and establish personal recommendations based on their particular and personal data. In order for the recommendations to be accurate, an appropriate combination of machine learning models and good quality data are required. Currently, both theoretical models [
4] and machine learning models (in particular deep learning based models [
3]) are being successfully applied to data obtained from blood glucose monitors (continuous glucose monitors or CGM) together with manually provided information, such as insulin bolus and meals. The sparsity of the data in both the insulin injection and meal intake signals represent a challenge for the convergence of machine learning models in general, and more especially for deep learning models in particular. A proper combination of machine learning models and theoretical physiological absorption models for insulin and carbohydrates could improve convergence and results for deep learning models. This paper uses a recurrent neural network (RNN) based on LSTM cells in order to estimate future levels of blood glucose based on past readings coming from a continuous blood glucose monitor (CGM), insulin injections, and carbohydrate intake and works on different absorption models to process the data available from real patients to obtain the best prediction of their next glucose levels and, thus, prevent possible rises or falls in the blood sugar level.
2. State-of-the-Art
Both insulin injections and carbohydrate intake have an important influence in blood glucose levels for type 1 diabetes mellitus (T1DM) patients. An optimal regulation will require a proper combination of timely injections of insulin boli, taking into account the amount of insulin units and the type of insulin to be used, to mitigate the timely effect caused by the exact amount of carbohydrates taken depending on the current and past levels of blood glucose. Several absorption models for insulin and carbohydrates have been proposed inside blood glucose regulation models in order to assess the influence over time of human actions (meal intake or insulin injections) into plasma concentration levels and, therefore, provide an estimation of the influence in blood glucose levels. Chiara et al. [
5] proposed a simulation model in normal humans, not suffering type 1 diabetes mellitus (T1DM), that describes the physiological events that occur after a meal. The parameters for the model were set to fit the mean data of a large normal subject database that underwent a triple tracer meal protocol which provided quasi-model-independent estimates of major glucose and insulin fluxes. A parametric model was developed by decomposing the system into subsystems. Wilinska et al. [
6] proposed a set of theoretical models for insulin lispro kinetics with bolus and continuous subcutaneous insulin infusion (CSII) modes of insulin delivery. Eleven alternative models of insulin kinetics were proposed. The models took into account several absorption configurations, taking into account different rates of absorption, and considering the influence of the volumes of insulin. The models also studied two pathways for insulin absorption (fast and slow) and were based on compartment divisions. Absorption models for insulin and carbohydrates can be expressed in mathematical terms in the form of differential equations. A particular mathematical representation can be found in Ruan et al. [
4]. The authors developed a new hierarchical model to relate subcutaneous insulin delivery and carbohydrate intake to continuous glucose monitoring over 12 weeks while describing day-to-day variability. A compartment model was proposed which comprised five linear differential equations. Hovorka et al. [
7] also proposed a compartment model, which represented the gluco-regulatory system and included submodels representing absorption of subcutaneously administered short-acting insulin Lispro and gut absorption, showing promising results. Hajizadeh et al. [
8] presented a plasma insulin concentration (PIC) estimator that incorporated Hovorka’s glucose-insulin model [
7] with the unscented Kalman filtering algorithm. The authors took interest in improving convergence. Haiya et al. [
9] modeled the insulin therapies using a delay differential equation model. The authors studied the dynamics of the model both qualitatively and quantitatively. An explanatory review about early mathematical models designed to understand the pathogenesis of diabetes is captured in [
10].
Machine learning techniques have also been used as an alternative method in order to estimate upcoming values of blood glucose (BG) levels. Machine learning methods are able to learn from the experience (using labeled training data) how to combine the information in the input glucose, carbohydrate, and insulin signals in order to minimize the errors in the prediction of upcoming BG levels (and, therefore, training a black box model that will simulate the underlying physiological model). Pappada et al. [
11] used a neural network-based (NN) model in order to estimate future values for blood glucose levels. The input signals for the model were food intake, insulin injections, and physical activity data. The author found that the proposed NN model worked well for anticipating hyperglycemic episodes (achieving accuracy values around 0.95 for a 60 min prediction horizon), but failed to predict hypoglycemic episodes. The authors in [
12] proposed a machine learning based model that could be trained for blood glucose prediction based on the use of a Kalman filter in order to estimate hidden values in the model. A support vector regression (SVR) algorithm was used to estimate upcoming values for BG levels taking into account the current and past levels of carbohydrates, insulin, and BG levels. The authors found that results were similar to those manually predicted by a doctor. The machine learning model proposed by the authors in [
13] was also based on an SVR model that, using the information provided by a single continuous glucose monitoring (CGM) device, tries to predict blood glucose levels independently of other factors. The results were able to improve those of other similar previous studies by adding differential evolution (DE) algorithms over data from 12 patients using CGM devices. The authors obtained average values for the root mean square error (RMSE) of 10.78 and 12.95 mg/dL for prediction horizons (PHs) of 30 and 60 min. Another machine learning model based on artificial neural networks (ANNs) for the blood glucose level prediction of type 1 diabetes (T1D) was proposed by Ali et al. [
14]. The authors proposed an improved method based on using only previous glucose levels as inputs. The results were validated on real CGM data of 13 patients, achieving RMSE values of 7.45 mg/dL and 9.03 mg/dL for prediction horizons (PHs) of 30 and 60 min. A meta-learning approach was proposed in [
15]. The authors proposed the idea of using regularized learning algorithms in predicting blood glucose. Meta-learning approaches are designed to be portable from patient to patient while outperforming other algorithms in terms of clinical accuracy.
Recently, some deep learning algorithms have also been applied for predicting upcoming BG levels trying to achieve a better performance compared to previously shallow methods. The authors in [
16], for example, described some methods for deep multi-output blood glucose forecasting. The results were validated using deep learning methods. The authors showed that deep learning models outperformed previous shallow learning alternatives. The study in Mhaskar et al. [
17] was also based on a deep learning approach in order to estimate upcoming BG levels. The study only used the previous BG levels in order to estimate future BG level values but using a pre-clustering mechanism to train specific models for hypo, eu, and hyperglycemic segments. Again, the authors showed that deep learning methods were able to outperform shallow network configurations.
In this manuscript, we propose and validate a new mechanism that incorporates physiological absorption models for insulin and carbohydrates into the pre-processing steps of a machine learning algorithm using a recurrent neural network based on LSTM cells. The learning algorithm is then able to learn the intricate dependencies between blood sugar levels and estimated values for blood insulin and carbohydrate concentrations trying to make it simpler for the model to learn.
3. Materials and Methods
To validate the methods proposed, the D1NAMO dataset [
18] has been used. It is a multi-modal dataset for research on non-invasive type 1 diabetes management. It contains data from 29 real participants, 20 of them used as healthy controls, and the other 9 patients with type 1 diabetes. The participants were monitored in the same way using the Zephyr BioHarness 3 wearable chest-belt device, recording information on the heart and respiration rates, and body acceleration. A continuous glucose monitoring (CGM) device was used to record glucose levels. The participants also recorded meals and insulin doses. Part of the information in the dataset will be used to train the machine learning models proposed in this paper and the rest of the data will be used for validating the results.
The information in the D1NAMO dataset [
18] is likely not to be complete. Meals and insulin injections were manually recorded by the participants and it is likely that some of the data values for some meals and insulin injections are missing. Several studies have highlighted the importance of having accurate data for meals. The study in [
19] analyzed CGM postprandial data and using fuzzy logic the authors were able to detect the majority of meals and many of the snacks. The authors in [
20] also used a set of rules to detect incorrect meal records. As a future work, we plan to use machine learning techniques to better detect missing or incorrect information in the annotated meals.
Table 1 captures the number of meals and insulin injections recorded by patient. The table also provides information about some incidences that have been observed in the meal information available. In order to get the best information to validate the methods proposed in this manuscript, only patients with IDs 1, 2, 4, 6, 7, and 8 have been used. Participant number 3 only recorded 3 meals and 3 insulin injections in 4 days and it is likely that most of the values are missing. Participant 5 did not provide information about the dates and times in which the meals were eaten. Participant 9 was also discarded since some of the information was manually assessed as missing.
There were 9 patients with normal outpatient lifestyles. Patients 003, 005, and 009 were not included in the study due to incompleteness in the meals and CGM data. Because of that, only 6 patients were included. Extended information about the relevant patients is shown in
Table 2.
The individual glucose statistics for the 9 patients are captured in Figure 6 in [
18].
3.1. Data Pre-Processing
The goal of the method proposed in this manuscript is to estimate the blood glucose (BG) level of patients using a prediction horizon (PH) of 60 min. For clarity, throughout this paper the unit mmol/L is used for blood glucose prediction. PHs of 30 and 60 min are common in previous research studies [
2,
14]. The latest 24 samples from the CGM device (2 h of data) are combined with the information from the insulin injections and carbohydrate intakes, together with the estimation of the physical activity, in order to estimate the value expected for the output of the CGM device with a prediction horizon of 60 min (12 samples) in advance. In order to combine the information from the different input signals, a data pre-processing module has been added to the proposed method. It is important to this subsection to describe the details for the pre-processing steps.
3.1.1. Glucose Data Pre-Processing
The BG signal is recorded from a continuous glucose monitoring (CGM) device providing an update every 5 min. The dataset provides the information for each participant in different files. The samples taken from the CGM device are organized in a different file per day. The BG signal pre-processing module will join the information in the different files and perform clock synchronization to a canonical time frame providing samples at a constant rate every 5 min.
Data are processed for each patient separately. By processing the data of patient 001, the signal from
Figure 1 is obtained.
After processing, glucose level values are obtained every 5 min for each patient. In order to fill in the training and validation subsets, two hour windows of data (24 values every 5 min from t-23 to t for every instant of time t) will be used to feed the input of a machine learning algorithm and the value after one hour (t + 12) will be used as the desired output. A sliding window mechanism will go through the entire BG signal for each participant and randomly assign each data window to the training or validation subsets.
3.1.2. Acceleration Data Pre-Processing
Acceleration data measures acceleration recorded from the accelerometer sensor worn by each patient. It is used to estimate if the patient performed physical activity in a time interval. Physical activity increases the consumption of blood glucose and has an impact on future values expected for the BG signal. The higher the intensity and duration of physical exercises, the lower the future glucose levels.
The acceleration data measured by the Zephyr Bioharness 3 device is used to estimate if the patient performed physical activity in a time interval. The acceleration is measured along 3 movement axis: vertical, lateral, and sagittal. This device has only been used during the day (the participants removed the band during the night for their convenience and comfort). The data pre-processing module only used fragments of data in which all the input signals were present in the dataset. Therefore, the segments during the night in which there was no information from the accelerometer were removed from the training and validation subsets.
The acceleration data sensor collects a sample every 10 ms. It is measured in gal (cm/s2). In
Figure 2, the x axis are the different samples along the time. The y axis shows vertical, lateral, and sagittal acceleration values measured in gal.
To process these data, the standard deviation () of 30,000 samples (in five minutes) is calculated. In this way the samples are adapted to the instants of time present on glucose measurements. The standard deviation from the past five minutes of acceleration data is associated with the glucose readings for that instant. The standard deviation of acceleration captures the intensity of the physical activity carried out in the past five minutes which will have an impact in upcoming glucose levels.
The standard deviation of the patient’s acceleration in the instants before taking the sample is calculated and the last five minutes of acceleration are taken. As the acceleration sensor takes 1 sample every 10 ms, 100 samples per second, and 6000 per minute are needed to do the five minutes. In total, 30,000 samples are required.
A 2-dimensional matrix is generated for acceleration data, the x axis being the different instants of time while the y axis captures the standard deviation of the past 30,000 samples measured in gal. The x axis are the different samples along the time and the y axis shows the standard deviation of 30,000 samples. The accelerometer provides acceleration data in three-dimensions, vertical, lateral, and sagittal. In
Figure 3 the processed acceleration levels are shown.
These values are used for the training vector in the models that include the acceleration values. The two hour values (24 values every 5 min from t-23 to t) and the value after one hour (t + 12) are used. That group composes a sliding window and forms a prediction sample. In x, the 24 values from the past are used. An attempt is made to predict, with the predicted value being “y prediction” and the dataset value being “y test”. Two-hour values are used (24 values every 5 min from t-23 to t). That group composes a sliding window and forms a prediction sample.
In x, the 24 values from the past are used. Depending on the model, different values of acceleration, insulin, or food are added for training.
“y predicted” corresponds to the predicted value by the model (at t + 12). “y test” value corresponds to the dataset glucose values (for all t + 12 samples).
3.1.3. Insulin Data Pre-Processing
Another input data signal used for glucose prediction is insulin. Type 1 diabetes patients need to take both fast and slow insulin doses in order to regulate BG levels all the time. In the dataset, these doses are injections of certain number of units of insulin. There are some models for insulin absorption by the human body [
9]. In this paper we use some of these insulin absorption models imitating the body’s absorption of insulin in order to pre-process the insulin data and study their implications in the accuracy achieved by a recurrent neural network (RNN) based machine learning model.
In the corpus used, two types of insulin are used: rapid-acting and slow-acting insulin. The major characteristics for each type of insulin are:
Rapid-acting insulin: Its effects begin between 5 and 15 min after your injection and have a peak of maximum effect of 1 to 2 h. Its action lasts between 4 and 6 h. This can vary a little depending on the dose of insulin administered and the specific type of insulin;
Slow-acting insulin: Its effects begin between 1 and 2 h after the injection and does not have an absorption peak, but its action is relatively flat and lasts between 12 and 24 h depending on the specific type of insulin administered. It is usually used at night due to its long duration.
The main research question addressed in this manuscript is analyzing the influence that modeling the absorption curves for insulin and carbohydrates in the human body in order to pre-process the insulin and meal input data will help to improve the accuracy in BG predictions in a PH of 60 min for a RNN based machine learning model. Several absorption models for insulin and carbohydrates have been implemented. In particular, for insulin, three different absorption models depending on the type of insulin have been used in this paper. Firstly, a linear-segment based approximation model for fast-acting insulin described in [
9] has been used. Secondly, the absorption profiles described in [
21]. Thirdly, the insulin absorption has been approximated using two concatenated exponential segments. A first increasing exponential will model the process in which the rate of absorption of the units of insulin taken is higher that the rate of insulin elimination by the human body and will end at the peak (maximum value for the plasma insulin concentration). A second decreasing exponential will model the second part of the curve in which the insulin elimination from the human body is predominant.
3.1.4. Haiya et al. Model
The model described in [
9] is based on a set of differential equations that describe the different processes in the human body to absorb insulin and carbohydrates. In particular, the insulin-independent glucose uptake follows a Michaelis–Menten kinetics in which the rate of enzyme reactions (
) is based on the composition of the substrate, as shown in Equation (
1).
where
is the maximum reaction speed for that substrate,
is the substrate concentration and
is the Michaelis constant.
To facilitate this absorption model, [
9] proposes a temporal approximation for rapid insulin. This model of absorption for rapid (Lispro) insulin is given by the Equation (
2).
where
is the insulin absorption (mU/L) and
t is the time in minutes.
Adapting Equation (
2) to take into account the insulin dose, Equation (
3) is obtained.
By analyzing the models for Lisro and Regular, two representations of insulin uptake are generated over time in
Figure 4a,b. Processing insulin over time produces a signal shown in
Figure 4c.
3.1.5. Insulin Absorption Profiles
In the
Table 3, different types of insulin and the duration of absorption are displayed [
22].
From the data in the
Table 4, action curves of the different types of insulin shown in the
Figure 5 have been generated [
9]. Similar models for time-action profiles of insulin preparations are captured in [
23].
Lispro insulin (in red) is very fast-acting. It starts working before the first 15 min (0.25 h). The peak is reached between the first and second hours, and lasts between four and six hours. Regular insulin (in blue) is fast-acting. It starts working after half or one hour. The peak is reached between the second and fourth hours, and lasts between six and eight hours. NPH insulin (in green) is intermediate-acting. It starts working in the first or second hour. The peak is reached between the sixth and tenth hours, and lasts more than 12 h.
In the dataset there is only Lispro (fast) and NPH (slow) intakes.
Firstly, these signals have been represented. Secondly, they have been multiplied by the units of insulin to take into account higher doses. Thirdly, the signal in
Figure 5 is obtained.
3.1.6. Insulin Absorption Exponentials
Another, simpler proposal is to take into account the data in
Table 4 to generate exponential signals increasing until the insulin peak and decreasing until the effect of insulin absorption ends.
This method obtains signals in
Figure 6a,b for both fast-acting and slow-acting insulin. It uses the data in
Table 4 to perform increasing exponentials until the insulin peak and decreasing until the effect of insulin absorption ends.
In
Figure 6a shows the fast insulin: the init is 15 min, the peak 120 min (2 h), and the duration is 300 min (5 h). In
Figure 6b appear the slow insulin: the init is 60 min, the peak 360 min (6 h), and the duration is 720 min (12 h).
Then, these exponential are applied to the patient data and the signal in
Figure 6c is obtained.
For this simulation, an exponential will be used that is increasing up to 15, 30, or 60 min depending on whether the food has less than 500 calories, between 500 and 900 or more than 900 calories, respectively, plus a decreasing exponential from the peak to completion. the 4 h of digestion. We will multiply the signal generated by the number of calories divided by 100 to have a higher peak when the calories ingested are higher.
3.1.7. Food Data Pre-Processing
Food intake has a direct impact on future blood glucose levels. To achieve a good prediction for upcoming blood glucose levels, two major parameters have a particular relevance: the amount of carbohydrates ingested and the glycemic index (which indicates how fast the glucose reaches the bloodstream).
The dataset [
18] used only contains information related to the amount of calories for some of the meals, annotated by a dietitian. The glycemic index was approximated using different absorption curves. Carbohydrate absorption curves have been modeled using the concatenation of an increasing and a decreasing exponential signals. In this way, we simulate how the ingested calories are absorbed over time and take into account how they affect the glucose level.
The rate at which carbohydrates are absorbed also depends on the chemical structure of the food. Some nutrients, such as cereals and derivatives, dairy products, fruits, legumes, and tubers, have a slower absorption while sugars, juices, soft drinks, or honey have faster absorption. In addition, the state of the food (solid or liquid) is also an influencing factor in the rate of absorption. As this information is not available in the dataset, a generic absorption curve in
Figure 7a is used for all the meals. This generic curve is applied to patient data and the signal in
Figure 7b is obtained.
3.1.8. Windowing the Input Signals
The model proposed uses the information from meals, insulin (both fast and slow acting), physical activity, and glucose measurements, from a continuous glucose monitoring device in the last 2 h in order to estimate the blood glucose (BG) level in the prediction horizon of 1 h. The input signals are sampled every 5 min. The pre-processed signals for each T1DM patient are then windowed in order to feed the machine learning model that will provide an estimation for the BG level in the prediction horizon of 60 min.
Figure 8 shows the samples taken in a window of data and the position in time samples for the predicted value:
Each window of input data will consist of 24 samples (2 h from t-23 to t) for each of the 4 or 5 pre-processed input signals: past blood glucose levels, physical exercise, fast insulin, slow insulin, and carbohydrates. In the different experiments carried out to validate the proposed model, not all of the configurations had carbohydrates signal. This way, it is possible to analyze the importance of carbohydrates in predicting upcoming values for blood glucose levels. Additionally, the glucose level for the following hour (t + 12) is necessary in order to validate the prediction.
For each window of input data, a single output value is recorded in the inference. The output it is the blood glucose level after the prediction horizon (one hour).
The different input windows will be generated using a sliding approach. A single sample in time will be removed and the next sample in time added in order to generate a new window of data. All the night measurements were eliminated due to the lack of acceleration data during that time.
The total number of windows of data have been generated for each participating patient. From the 9 participants in the dataset [
18], 6 patients have been selected because of the completeness of the available data. After pre-processing, there are a total of 4 or 5 input signals (blood glucose, fast acting insulin, slow acting insulin, carbohydrates, and physical activity) that provides samples every 5 min. These signals are windowed as shown in
Table 4.
The patients with the highest number of windows are patients 001 and 008. It is expected to obtain better results with this patients.
3.2. LSTM Based RNN Proposed Architecture
To make the prediction of the patient’s blood glucose level in the prediction horizon (PH) of one hour after data acquisition, an LSTM long short term memory (LSTM) based recurrent neural network (RNN) model is proposed. A single LSTM layer is used as in previous studies, such as [
3,
24]. Deeper architectures, such as [
25], have shown better prediction performance. However, the objective of the current manuscript is to compare how much a machine learning model can learn from pre-processed carbohydrate an insulin signals according to different absorption models and not to compare different machine learning methods.
A regression problem is solved using a RNN based model in order to assess the impact of different absorption curves for carbohydrates and insulin. A more complex (deeper) architecture for the machine learning method is likely to partially compensate a certain degree of inaccuracy in the absorption model. The model in [
3] used a single layer bi-directional LSTM with 8 memory cells but added several dense layer after the bidirectional LSTM expanding the state to up to 64 hidden neurons. The model in [
24] used a single LSTM layer with several configurations for the internal number of memory state cells, ranging from 8 to 128. A similar model in complexity will be used in this manuscript with a single LSTM layer of 56 memory units. Finally, a 1 unit output dense layer is added as the prediction of the blood glucose level is a single scalar value.
Figure 9 shows the architecture for the machine learning model used:
The total complexity of the model could be assessed by the number of trainable weights. There is a total of 13664 weights in the LSTM part of the model and 57 on the output dense layer. The input shape in order to feed the model is (None, 24, 4) or (None, 24, 5). Each sample for training or testing the model will be a bi-dimensional tensor with 24 time samples for 4 or 5 input signals. The first “None” parameter refers to a variable number of samples that can be fed to the model at the same time. The output shape of the LSTM is (None, 56) and the output shape of the dense layer is (None, 1), providing a single estimate for each input tensor.
The model has been implemented in Keras [
26] as a sequential model and compiled by evaluating the loss function using the root mean square error (RMSE).
3.3. Train, Validation, and Test Separation
The model is fed with part of the windows of the input data for training (the training set) and the achieved score for the fidelity in the reconstruction for the predicted glucose level will be computed using a different set of input windows (test set). The training and test sets split is randomly done. The model is trained independently for each patient using 80% of the data. The remaining 20% is used for calculating the final score as testing data.
The training data are further divided into training and validation subsets that are taken into account for training the machine learning algorithm. From the training data, 75% of the windows are used for training and the remaining 25% for validating the convergence of the training process every iteration (epoch).
3.4. Evaluation Metric
The prediction evaluation is based on the losses obtained in the test samples when estimating the blood glucose level in a prediction horizon (PH) of 60 min. The loss function used is root mean square error (RMSE). Thus, the lower the error obtained, the better the predictions made by the model. The idea is that when prediction errors are small, the machine learning model is able to learn the internal patterns that transform the input signals into the output estimation.
3.5. Training the Model with 7 Configurations
A set of 7 experiments has been designed in order to pre-process the input data to train the machine learning model in
Figure 9. Each experiment simulates a different absorption function for carbohydrates and insulin. The configurations for each experimental case are fully described in the next section.
The training process will run for a fixed number of iterations called epochs using a batch of instances to compute the gradients for numerical optimization. Every batch will provide an update in the weights of the model. In our case, the value of batch size is 16 and the number of epochs has been set to 150. These values have been selected in order to avoid over-fitting and under-fitting. In the case of over-fitting, the model would only adjust to particular cases and could not recognize new data. Additionally, in the case of under-fitting, the training would be insufficient and unable to make a good prediction.
4. Experiments Configuration Description
The blood glucose kinetics in the human body is a complex process that has been modeled in previous studies using a set of differential equations (Haiya et al. [
9]). The intake of carbohydrates and insulin injections generate absorption processes that end up in having an influence in the future evolution of blood glucose levels. When trying to use a machine learning model to estimate future values for blood glucose concentrations, such as the model in
Figure 9, the complex mechanisms in the human body should be learned by the model in order to transform the values for the input signals into prediction values which are as close as possible to the real ones. The objective of this manuscript is to assess the impact on the learning process by the machine learning model when providing additional information to the input data so that the amount of information that the model has to learn is minimized. In order to feed the machine learning model with input data which are closer to the physiological processes in the human body, the carbohydrate intake information and the insulin injection data will be converted into absorption curves using different absorption models. The amount of carbohydrates and insulin units will be convoluted with different models to approximate the meal digestion and insulin absorption by the human body. Different absorption curves have been used in order to generate different experiments. A description of each experiment is captured in this section while the particular results for each of them are described in the next section. In order to be able to compare these results in an impartial way, 10 different executions for each patient for each experiment set up have been carried out, using for each one of the executions, the same datasets (same time instants) for testing, training, and validation so that the results are comparable.
Table 5 summarizes the input signals used for each of the experiments and the absorption signal used for slow and fast insulin and to simulate food digestion. All the experiments use the raw glucose signal, as well as an estimation for how vigorous the physical activity is. The major differences are in the signals used to pre-process insulin and carbohydrates.
4.1. Experiment 1 Configuration
As captured in
Table 5, the first experiment uses the raw samples for blood glucose, fast acting insulin, and slow acting insulin. The standard deviation of the acceleration data is added to this input to consider the physical activity of the patient. This first model does not have into account the information of the patient’s meals. The information about meals in the D1NAMO dataset [
18] is based on the visual estimation for carbohydrates made by a nutritionist after analyzing the photos of the food taken by each participant. Some participants did not record all the meals. For some participants there were duplicated data. Finally, the exact time for the ingestion of the meals is not known and has been estimated by the time in which the photo was taken (assuming that it was take immediately before having the meal). For all of these reasons, we have left apart the information about meals in the first experiments and only used it in the last ones.
4.2. Experiment 2 Configuration
The second experiment also uses the glucose samples as an input. The standard deviation of the acceleration data is also added to this input to take into account the physical activity of the patient. Finally, the information for both fast and slow acting insulin is pre-processed using an exponential increasing and then decreasing absorption curve. The idea is that a simple absorption curve with and exponential decay will approximate the insulin absorption by the human body and, therefore, contribute to improve the estimation of the blood sugar levels that the patient will have one hour after the instant in which the prediction is made. In this experiment, as in the previous one, the information of the patient’s meals will not be taken into account.
4.3. Experiment 3 Configuration
The third experiment also uses the glucose signal and the standard deviation of the acceleration data as inputs, as in the previous experiments. The pre-processing for slow acting insulin uses the same simple absorption curve as in the previous experiment based on the concatenation of two exponential-shaped segments. The novelty of the experiment is for the pre-processing of the fast acting insulin which has been modeled following the proposal in Haiya et al. [
9] and given by the Equation (
2). The pre-processing model is expected to better describe the insulin absorption process in the human body and simplify the training for the machine learning model. In this experiment, as in the previous two, the information of the patient’s meals will not be taken into account.
4.4. Experiment 4 Configuration
The fourth experiment is based on experiment number 2 adding some basic information about meals. As in experiment number 2, the glucose samples are used together with the standard deviation of the acceleration data as a meter for the physical activity of the patient. As in experiment 2, the pre-processed fast and slow insulin are added as an increasing and then decreasing exponential depending on the type of insulin. The novelty for experiment number 4 is that we add the raw values for the meals as the estimated amount of calories taken in the instant of time in which the picture of the meal was taken. Carbohydrates play a crucial role on guiding the blood glucose kinetics and even with partial and not accurate estimations, the model is expected to be able to improve predictions.
4.5. Experiment 5 Configuration
The fifth experiment is based on experiment 4 but simulating the carbohydrate absorption using an exponential-shaped curve similar to the curve used for insulin absorption. The peak time is adjusted to simulate the digestion process. The past values for blood glucose levels, the standard deviation of the acceleration data and the pre-processed insulin following exponential-shaped absorption curves are used, as in experiment 4. The carbohydrate absorption curve will approximate the meal digestion process and we expect that the machine learning model will be able to achieve better prediction results.
4.6. Experiment 6 Configuration
The sixth experiment is based on experiment number 3 but adding the digestion approximation based on exponential-shaped absorption curves as in experiment number 5. The major difference with experiment number 5 is the use of the proposal in Haiya et al. [
9] and given by the Equation (
2) in order to approximate the fast acting insulin absorption.
4.7. Experiment 7 Configuration
The last experiment has used the activity profiles of different types of insulin in [
22] in order to approximate the insulin absorption for both slow and fast acting insulin. The seventh experiment will use the glucose samples taken in the 24 moments prior to the prediction, corresponding to 2 h of patient monitoring and the standard deviation of the acceleration data as an indicator for physical activity, as in all the experiments. The information about meals will be pre-processed using the exponential-shaped curve. The major difference will be the use of absorption curves for insulin which will follow measured profiles according to the type of insulin.
6. Comparison with Similar Previous Studies
Absorption models for carbohydrate and insulin which mimic the human body absorption processes have been proposed in the previous sections, showing that for the D1NAMO dataset [
18] the accuracy achieved by a machine learning model (shown in
Figure 9) when estimating future values for blood glucose levels with a 60 min prediction horizon significantly improves as compared with the base case in which raw data for food and insulin are used. In this section, a comparison with previous studies using a similar machine learning model when applied to raw data in different datasets in order to obtain predictions for future values for blood glucose levels will be presented in order to generalize results to different datasets. In order to make a fair comparison between different previous studies, some characteristics are required:
Model input: datasets containing CGM data for real participants, not simulated patients. Simulators normally capture simplified models with less complex patterns and machine learning models tend to provide better results for simulated data;
Prediction horizon (PH): 60 min. Previous studies have used 30 and 60 min prediction horizons. The bigger the PH the less accurate the estimations will be;
Method used: recurrent neural network–long short term memory. RNN with LSTM cells is the machine learning model selected in the current manuscript and has been successfully used in previous studies. In order to have a fair comparison of results among different studies, the complexity of the models measured as the number of trainable parameters should be similar. The model used in this paper uses a single LSTM layer with 64 memory cells and an output dense layer with a single neuron. Using more complex models with more layers will be able to learn more complex patterns from the data providing better results. However, the objective of the current manuscript is not to optimize the machine learning model but to compare how a single model will be able to learn the different patterns from data using different absorption curves;
Pre-processing: in order to study the effect of insulin and carbohydrate absorption curves, this paper has defined and measured the results for experiment 1 in which raw data were used to train the model (no absorption curves were used for experiment 1). Previous papers with no pre-processing are going to be compared with experiment 1 in this manuscript;
Output error values: RMSE for blood glucose level predictions are used. In the present work the values are in mmol/L. However, the values are converted into mg/dL because this unit is used more often in previous studies.
Table 8 summarizes the comparison with similar previous studies. Sun et al. [
3] and Martisson et al. [
24] used a similar RNN–LSTM one layer machine learning model applied to data from real participants. The prediction horizon was 60 min in both cases. No pre-processing for the insulin and carbohydrate signals was used. The results show worse figures for BG prediction values (RMSEs of 36.918 and 33.2 (mg/dL)) as compared to the results obtained in this paper for experiment 1.
In this work, the RMSE values have been computed with glucose levels in mmol/L. However, it is important to convert the units to mg/dL. In case of the first experiment, the result is 0.863 (mmol/L) = 15.5 (mg/dL). The result is improved in the fifth experiment with a mean value of 0.510 (mmol/L) = 9.2 (mg/dL).
De Bois et al. [
2] found better results using a similar machine learning model than the base experiment 1 in this paper. They achieved an RMSE value of 7.08 mg/dL. The model architecture is quite similar. However, the data were for simulated patients and the prediction horizon considered was 30 min. Hence, their research work faced a more favorable case which is, therefore, not fully comparable to the results in this paper.
Munoz-Organero [
25] also obtained better results than the base experiment in this paper. In this case, the study used the same dataset and prediction horizon getting results of 6.42 mg/dL. However, the research study in [
25] used a more complex machine learning model which included pre-processing stages to simulate the carbohydrate and insulin absorption by the human body. Using absorption curves, as proposed in this paper, the intuition is that the input data to the machine learning model reduces the complexity of the patterns to be learnt as compared to models, such as [
25], which propose deeper architectures that try to learn absorption curves based on raw data. Deeper models require more data to be trained which in some cases could require T1DM patients to have to train the system for a longer period of time before being able to use it.
Data in
Table 8 show that a simple machine learning model can better learn from data if absorption curves for insulin and carbohydrate are used and achieve results similar to those of a more complex model. As a future work we will apply absorption curves to more complex models in order to optimize prediction results. Different absorption curves in insulin and food carbohydrates have been studied showing the improvement of results.
7. Discussion
Diabetes is one of the most frequent chronic diseases that does not have a cure and an exact treatment. Additionally, there are some complications attached, such as dementia, heart attacks, chronic dermatitis, and lack of blood supply. Diabetic patients should avoid hypoglycemia and hyperglycemia episodes. Machine learning predictive models have shown to provide good results for estimating future values for BG levels. Using these estimations, T1DM patients are able to adjust insulin and carbohydrate intakes and prevent hypoglycemia and hyperglycemia episodes. Moreover, the quality of life of patients could be improved and healthcare costs reduced. That is possible by predicting accurate blood glucose levels in the near future in diabetic type I patients.
The results in this manuscript show that machine learning models for predicting upcoming values for BG levels can better learn if absorption curves are used in order to pre-process insulin and carbohydrate raw data. A PH of 60 min has been used.
In this work, data from 9 patients suffering type 1 diabetes have been considered. Some control variables are physical exercise, food intake, injected insulin, and the body’s absorption processes. It has been necessary to perform a pre-experiment data quality assessment because inaccurate input values can negatively affect the results for the machine learning algorithm. Out of the 9 patients, 6 participants have been finally selected removing those that were suspected to have important information missing or duplicates.
Four ways of insulin absorption modeling have been used. First of all, no absorption model has been studied in order to have a base scenario and to facilitate the comparison with previous studies. Secondly, a linear model described in [
9] has been used. Thirdly, assimilation curves directly provided by the insulin manufacturer have been studied. Lastly, a new model with exponential curves was developed for this work.
Additionally, there are two types of insulin used in the dataset: fast acting which lasts between 4 and 6 h and slow acting, which lasts between 12 and 24 h.
The machine learning model used is based on RNN with LSTM cells which has been widely used in previous studies, such as Sun et al. [
3] and Martisson et al. [
24]. For evaluating the performance of the models, a root mean square error (RMSE) based loss function has been used. The smaller the error found in the test data, the better for the model and the predictions.
Results show that using the exponential model the predictions of the blood glucose levels in the next hour improve for the majority of patients. To verify this, different tests were carried out modifying the absorption models and carrying out 10 different executions in each test.
The achieved results are encouraging, obtaining accuracy levels around 0.510 mmol/L (9.2 mg/dl) in the best scenario.
The results are promising, with low errors in the prediction horizon even for a simple machine learning model. The conclusion is that a simple model with good pre-processing of signals for real patient data can improve the performance of the prediction.
Some applications of this work in diabetes are improvements in blood glucose control, recommendations, nutritional advice, individualized treatment, as well as blood glucose level regulation when monitoring night-time insulin values with an insulin pump.
Future improvements include designing an automatic control system. For example, an artificial pancreas that controls the amount of insulin that is injected, to be able to do it automatically at times when the patient cannot. When controlling the amount, the glucose prediction values for the near future are used, since there is a relationship between glucose levels and the amount of insulin needed.
Regarding future work, we expect to improve the model, optimizing the hyperparameters and modifying the number of layers or memory cells.