# A Recurrent Neural Network Approach for Predicting Glucose Concentration in Type-1 Diabetic Patients

Fayrouz Allam, Zaki Nossai, Hesham Gomma, Ibrahim Ibrahim, Mona Abdelsalam

► To cite this version:

Fayrouz Allam, Zaki Nossai, Hesham Gomma, Ibrahim Ibrahim, Mona Abdelsalam. A Recurrent Neural Network Approach for Predicting Glucose Concentration in Type-1 Diabetic Patients. 12th Engineering Applications of Neural Networks (EANN 2011) and 7th Artificial Intelligence Applications and Innovations (AIAI), Sep 2011, Corfu, Greece. pp.254-259, 10.1007/978-3-642-23957-1_29. hal-01571345

HAL Id: hal-01571345

https://inria.hal.science/hal-01571345

Submitted on 2 Aug 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Recurrent Neural Network Approach for Predicting Glucose Concentration in Type-1 Diabetic Patients

Fayrouz Allam¹, Zaki Nossair², Hesham Gomma², Ibrahim Ibrahim²,
Mona Abdelsalam³

¹Tabbin Institute for Metallurgical Studies, Helwan, Egypt

²Faculty of Engineering, Helwan Univ., Egypt

³ Faculty of Medicine, Ain Shams Univ., Egypt

**Abstract.** Estimation of future glucose concentration is important for diabetes management. To develop a model predictive control (MPC) system that measures the glucose concentration and automatically inject the amount of insulin needed to keep the glucose level within its normal range, the accuracy of the predicted glucose level and the longer prediction time are major factors affecting the performance of the control system. The predicted glucose values can be used for early hypoglycemic/hyperglycemic alarms for adjustment of insulin injections or insulin infusion rates of manual or automated pumps. Recent developments in continuous glucose monitoring (CGM) devices open new opportunities for glycemia management of diabetic patients. In this article a new technique, which uses a recurrent neural network (RNN) and data obtained from CGM device, is proposed to predict the future values of the glucose concentration for prediction horizons (PH) of 15, 30, 45, 60 minutes. The results of the proposed technique is evaluated and compared relative to that obtained from a feed forward neural network prediction model (NNM). Our results indicate that, the RNN is better in prediction than the NNM for the relatively long prediction horizons.

**Keywords:** glucose concentration prediction; type-1 diabetes; neural networks

## 1 Introduction

The current trend in research is to automatically monitor the blood glucose level and inject the insulin needed to regulate the patient glucose level. Continuous glucose sensors can be coupled with continuous insulin infusion pumps to create a closed-loop artificial pancreas. The model which is used in MPC is required to accurately predict the glucose level for long prediction horizons to compensate for the delay between the CGM readings and the blood glucose values. Since glucose-insulin interaction is a nonlinear, therefore, modeling using neural network as a nonlinear system will give better results [1]. However, if the model is required to predict more than one time step ahead, recurrent neural networks should be used. Neural network techniques have been used in the past for predicting glucose levels using CGM readings as input and also within glucose control systems [2]. Oruklu et al., [3] proposed the development of the empirical models that use frequently sampled glucose data. They used autoregressive moving average (ARMA) to predict the future glucose concentration. Their model is based on the virtual subject's glucose concentration obtained from
Hovorka model, and they simulate the CGM data by adding Gaussian noise to the synthetic data. The PH of their model is 30 minutes (6 steps) ahead prediction. Zainuddin et al. [4] developed four different feed forward wavelet neural networks for four intervals: morning, afternoon, evening and night, in order to predict the blood glucose at the end of each interval. The patients need to fill in information about time of glucose measurements, blood glucose values, insulin doses, food, exercises and stress. Perez et al., [1] present a NNM which can predict future glucose concentration from previous 5 glucose CGM samples and the current time stamp, while the output is the glucose concentration at the chosen PH. Three different PHs are used: 15, 30, and 45 min. Their model suffers from time delay between the original and predicted glucose concentration. Gani et al., [5] developed a glucose prediction autoregressive (AR) model of order 30 to make short term, 30-minutes ahead prediction time, without time lag. Pappada et al., [6] used a dataset of different patients obtained by CGM to construct a neural network using NeuroSolutions® software to predict glucose concentration while time varying predictive window from 50-180 minutes is used. In this paper, we present a new prediction algorithm based on a RNN. It is a fully automated prediction system which doesn't need any data to be entered from patients such as in [4]; therefore our proposed prediction algorithm is more convenient to be used during sleeping hours.

## 2 Subjects and Dataset

The evaluation of the proposed algorithm is performed using glucose measurements from 9 type-1 diabetic patients, the average duration of glucose measurements for each patient is 2 days, 288 samples for each day. The glucose measurements for the 9 patients were obtained using Gaurdian® Real Time CGM system (Medtronic-Minimed) which provides a glucose reading every 5 minutes. Our data set consists of 4916 samples. This data is divided into two different subsets, one subset is for training and the second is for testing and validating the model. The data was smoothed using low pass filter of order 11 before using it in training and testing the neural networks. The use of smoothed version of the CGM data reduces the time lag between the predicted glucose and measured glucose values [5].

## 3 The Proposed Algorithm

Our proposed prediction algorithm uses CGM readings only, it is like a nonlinear AR model. Both inputs and delayed feed backed outputs are glucose concentration values. Fig. 1 shows the architecture of the RNN predictor. The input $u_i$ is the glucose reading of sample i (current glucose value), and the output $y_i$ is the predicted glucose reading at time i+PH. The input $u_i$ is entered to a tapped delay line (TDL) element to hold the previous glucose readings, $u_{i-1},...,u_{i-N}$, where N is the number of inputs. The initial outputs from this TDL are $u_1$ to $u_N$ [means the glucose readings $G_1, G_2, G_3, G_4,...,G_N$]. The network has also feedback input which is the output $y_i$ that enters to another TDL to hold $y_{i-1},...,y_{i-M}$, where M is the PH divided by 5 minutes sampling period. The initial outputs from this (TDL) are $y_1$ to $y_M$ [means glucose readings $G_{N+1},...,G_{N+M}$]. The input $u_i$ is updated at each new sample time by the glucose reading from the CGM sensor, this means that the prediction is based on the
most recent N readings of the glucose concentration. For example, if the pH is 25 minutes, and the input is u₆ [i.e. G₆], then the predicted glucose will be y₆ which is an estimate for G₁₁. The available initial offline inputs are the first 10 samples of glucose, the first 5 samples are applied directly to the inputs and the samples from G₆ to G₁₀ are applied one after the other, therefore the predicted output will be G₁₁ to G₁₅, which means 5 step ahead prediction, (each step represents 5 minutes), therefore it performs 25 minutes prediction.

<figure><img src="image_2.png" /><figcaption>Fig. 1. The architecture of the RNN which is used in the prediction algorithm.</figcaption></figure>

## 3.1 Evaluation Metrics

The performance of the proposed prediction algorithm is evaluated using several metrics: root mean squared error (RMSE) in mmol/L, FIT, and normalized prediction error (NPE). These metrics have the following expressions.

$$RMSE = \sqrt{\frac{\sum_{i=1}^{N} (G_i - \hat{G}_i)^2}{N}} \qquad (1)$$

$$FIT = (1 - \frac{\left| G_i - \hat{G}_i \right|}{\left| G_i - \bar{G} \right|}) \times 100 \qquad (2)$$

$$NPE = \sqrt{\frac{\sum_{i=1}^{N} (G_i - \hat{G}_i)^2}{\sum_{i=1}^{N} G_i^2}} \qquad (3)$$

Where Gᵢ is the glucose reading of sample i, N is the total number of samples, ̂Gᵢ is the estimated glucose value of sample i, Ḡ is the mean of all glucose readings. In addition to the above three metrics, the Clarke error grid approach (Clarke's EGA) [7] was also used to assess the performance of the prediction algorithm with a clinically acceptable metric.

## 3.2 Experiments and Results

Many network architectures for the RNN are tested to optimize the predicted output. Two hidden layers and 20 neurons in the first hidden layer were found to give the best results. The prediction performance of the network is evaluated
(by calculating FIT) for various numbers of inputs, when the number of inputs is changed; the network architecture that optimizes the predicted output is changed, as shown in table 1. Table 2 shows the evaluation measures calculated for several PH values when using 20-13-1 architecture which gives the best predicted output (from table 1). Table 3 shows the error matrix of EGA which contains the percentage of predicted samples that are located in each zone for different PHs.

<table><caption>**Table 1.** FIT values when using various number of inputs and PH=40 min. for different network architectures</caption><thead><tr><td>No. of inputs</td><td>Network Architecture</td><td>FIT (%)</td></tr></thead><tbody><tr><td>30</td><td>20-7-1</td><td>72.16</td></tr><tr><td>30</td><td>20-8-1</td><td>65.18</td></tr><tr><td>30</td><td>20-10-1</td><td>74.5</td></tr><tr><td>40</td><td>20-10-1</td><td>76.72</td></tr><tr><td>40</td><td>20-13-1</td><td>77.21</td></tr><tr><td>40</td><td>18-13-1</td><td>68.24</td></tr><tr><td>50</td><td>18-13-1</td><td>71.5</td></tr><tr><td>50</td><td>20-13-1</td><td>76.15</td></tr></tbody></table>

<table><caption>**Table 2.** Values of RMSE, FIT and NPE when using 40 inputs and (20-13-1) for different PHs</caption><thead><tr><td>PH</td><td>FIT (%)</td><td>RMSE (mmol/L)</td><td>NPE (%)</td></tr></thead><tbody><tr><td>15</td><td>95.33</td><td>0.14</td><td>1.7</td></tr><tr><td>30</td><td>85.83</td><td>0.42</td><td>5.27</td></tr><tr><td>45</td><td>72.3</td><td>0.84</td><td>10.28</td></tr><tr><td>60</td><td>56.61</td><td>1.32</td><td>16.2</td></tr></tbody></table>

## 4 Performance Comparisons

The RNN gives more accurate predicted output than the NNM because the relationship between glucose concentration and time is highly dynamic. Many NNM architectures are tested to choose the ones that give the best predicted output, the best architectures were 15-10-1, 15-13-1, 16-13-1, 20-13-1 for PH of 15, 30, 45 and 60 minutes respectively. Fig. 2 shows the difference in prediction accuracy between the NNM and the RNN for various PHs. Table 3 shows Clarke's EGA to clinically evaluate the predicted output from the NNM and RNN.

<table><caption>**Table 3.** The Clarke's EGA for Feed Forward Network's Output at Different PHs.</caption><thead><tr><th></th><th colspan="2">A</th><th colspan="2">B</th><th colspan="2">C</th><th colspan="2">D</th><th colspan="2">E</th></tr><tr><th>PH</th><th>NNM</th><th>RNN</th><th>NNM</th><th>RNN</th><th>NNM</th><th>RNN</th><th>NNM</th><th>RNN</th><th>NNM</th><th>RNN</th></tr></thead><tbody><tr><td>15</td><td>100</td><td>100</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>30</td><td>98.5</td><td>98.6</td><td>1.47</td><td>1.3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>45</td><td>86.7</td><td>91.5</td><td>10.5</td><td>8.4</td><td>0</td><td>0</td><td>2.7</td><td>0</td><td>0</td><td>0</td></tr><tr><td>60</td><td>42.09</td><td>78.7</td><td>50.42</td><td>19.3</td><td>0</td><td>0</td><td>5.98</td><td>1.95</td><td>1.49</td><td>0</td></tr></tbody></table>

Table 3 shows that, for PHs less than 60 minutes, all the predicted values are located in clinically accepted zones A and B for RNN. At PH of 45 minutes, 2.7% of predicted outputs from the NNM lay in zone D. At PH of 60 minutes, there are 1.95% for RNN and
<figure><img src="image_3.png" /><figcaption>Fig. 2. The RNN and NNM prediction results for PH of (a) 15 min., (b) 30 min., (c) 60 min.</figcaption></figure>

5.98% for NNM of predicted samples located in zone D, which can lead to incorrect treatments and detections. Table 4 shows the RMSE for results that are obtained from the RNN and the SVR model used in [8].

<table><caption>**Table 4.** RMSE values for RNN prediction model and SVR based prediction model.</caption><thead><tr><th>Prediction model</th><th>15 min.</th><th>30 min.</th><th>60 min.</th></tr></thead><tbody><tr><td>RNN model</td><td>0.14</td><td>0.55</td><td>1.32</td></tr><tr><td>SVR model</td><td>0.52</td><td>0.89</td><td>1.37</td></tr></tbody></table>

# 5 Discussion

From all of the previous results it can be seen that, at PH= 30 min., there is no time delay in the predicted output from both the RNN and NNM. At PH=45 min., there is a wider oscillation in the predicted profile of the NNM's output. These oscillations result in a large model prediction error. The NNM failed to predict the output for PH=60 min. For short prediction horizons our proposed RNN algorithm is comparable with others that use recurrent networks such as [9] in which they used 6 RNNs to implement the Hovorka diabetic patient physiological model. Our model used real readings of glucose obtained using CGM, and trained one RNN to predict future values of glucose. This difference makes our model more simple and based on real data instead of synthetic data. The model of Huang et al. [9] gives FIT=80.9% for PH=30 min., which is less than our result for the same PH. Our results for long PH are
still incomparable with that of other algorithms that are trying to predict for longer
PHs such as in [9] which predicts 2 and 4 hours.

5 Conclusion

Training the RNN using data obtained from a CGM device, which continuously reads
the glucose during the full day for different patients, gives our model some generality.
The RNN needs some fine tuning when it is used with a specific patient. This is one
of the differences between our model and some others such as [5]. Our RNN can
accurately predict the glucose values for PH=30 minutes without time delay. At
PH=45 minutes the RNN can predict with very little time delay and with acceptable
accuracy. But its accuracy is deteriorated for 60 minutes prediction. It is better to use
the RNN than the NNM in prediction especially at longer PH, where the accuracy of
the NNM is highly deteriorated. Clarke's EGA indicated that the performance of the
proposed RNN prediction model is also significant from a clinical point of view. We
conclude that, the RNN prediction algorithm succeeds to predict the future glucose
values from CGM systems. It can be used for online glucose prediction in model
prediction control systems.

References

1. Pe'rez-Gandi'a, C., Facchinetti, A., Sparacino, G., Cobelli, C., Go'mez, E.J., Rigla, M., de Leiva, A., Hernando, M.E.: Artificial Neural Network Algorithm for Online Glucose Prediction from Continuous Glucose Monitoring. Diabetes Technology & Therapeutics. 12, 81--88 (2010)

2. Mougiakakou, S.G., Nikita, K.S.: A neural network approach for insulin regime and dose adjustment in type 1 diabetes. Diabetes Technol Ther. 2, 381-389(2000)

3. Oruklu, M.E., Cinar, A., Quinn, L., Smith, D.: Adaptive control strategy for regulation of blood glucose levels in patients with type 1 diabetes. Journal of Process Control. 19, 1333-1346 (2009).

4. Zainuddin, Z., Pauline, O., Ardil, C.: A Neural Network Approach in Predicting the Blood Glucose Level for Diabetic Patients. International Journal of Information and Mathematical Sciences. 5:1, 72--79(2009)

5. Gani, A., Gribok, A.V., Lu, Y., Ward, W.K., Vigersky, R.A., Reifman, J.: Universal Glucose Models for Predicting Subcutaneous Glucose Concentration in Humans. IEEE Transactions on Information Technology in Biomedicine. 14, 157--165(2010)

6. Pappada, S.M., Brent, B.S., Cameron, D., Rosman, P.M.: Development of a Neural Network for Prediction of Glucose Concentration in Type 1 Diabetes Patients. Journal of Diabetes Science and Technology. 2, 792--801(2008).

7. Clarke, W.L.: The original Clarke error grid analysis (EGA). Diabetes a Technol. Ther. 7, 776--779 (2005)

8. Georga, E., Protopappas, V.C., Fotiadis, D.I.: Predictive Modeling of Glucose Metabolism using Free-living Data of Type 1 Diabetic Patients. In: Annual International Conference of the IEEE, pp. 589 – 592. Engineering in Medicine and Biology Society (EMBC) (2010)

9. Huang, H.P., Liu, S.W., Chien, I.L., Lin, C.H.: A Dynamic Model with Structured Recurrent Neural Network to Predict Glucose-Insulin Regulation of Type 1 Diabetes Mellitus. In: Proceedings of the 9th International Symposium on Dynamics and Control of Process Systems (DYCOPS 2010), pp. 228--233, Belgium (2010)