Abstract
Background:
In type 1 diabetes (T1D) therapy, the calculation of the meal insulin bolus is performed according to a standard formula (SF) exploiting carbohydrate intake, carbohydrate-to-insulin ratio, correction factor, insulin on board, and target glucose. Recently, some approaches were proposed to account for preprandial glucose rate of change (ROC) in the SF, including those by Scheiner and by Pettus and Edelman. Here, the aim is to develop a new approach, based on neural networks (NN), to optimize and personalize the bolus calculation using continuous glucose monitoring information and some easily accessible patient parameters.
Method:
The UVa/Padova T1D Simulator was used to simulate data of 100 virtual adults in a single-meal noise-free scenario with different conditions in terms of meal amount and preprandial blood glucose and ROC values. An NN was trained to learn the optimal insulin dose using the SF parameters, ROC, body weight, insulin pump basal infusion rate and insulin sensitivity as features. The performance of the NN for meal bolus calculation was assessed by blood glucose risk index (BGRI) and compared to the methods by Scheiner and by Pettus and Edelman.
Results:
The NN approach brings to a small but statistically significant (P < .001) reduction of BGRI value, equal to 0.37, 0.23, and 0.20 versus SF, Scheiner, and Pettus and Edelman, respectively.
Conclusion:
This preliminary study showed the potentiality of using NNs for the personalization and optimization of the meal insulin bolus calculation. Future work will deal with more realistic scenarios including technological and physiological/behavioral sources of variability.
Daily management of type 1 diabetes (T1D) requires patients to perform a huge number of actions to keep their blood glucose (BG) level within the euglycemic range. 1 In particular, a delicate task is the determination of the amount of insulin to be injected at mealtime. Bolus calculators (BCs) are tools conceived to ease patients from such a burden. 2 They are either software tools integrated in commercialized insulin pumps or stand-alone devices/mobile applications. The effectiveness of BCs in improving T1D management has been widely proved.3,4 In general, BCs implement the following standard formula (SF):
where B (U) is the insulin bolus amount needed to compensate for the intake of a certain quantity of carbohydrates (CHO) (g), CR and CF are, respectively, the insulin-to-carbohydrate-ratio (g/U) and the correction factor (mg/dL/U), that is, two patient-specific therapy parameters usually tuned-up by physician according to trial-and-error procedures,5,6 GC is the measured BG level (mg/dL), GT is the target BG concentration (mg/dL) and IOB (U) is the insulin on board, that is, an estimate of how much previously injected insulin is still acting in the body. 2
In equation (1), GC is normally measured by self-monitoring of blood glucose (SMBG). Recently, US Food and Drug Administration approved some continuous glucose monitoring (CGM) devices to be used nonadjunctively, that is, CGM data can be used for insulin dosing without any confirmatory SMBG measurement.7,8 In such a nonadjunctive CGM context, an intuitive approach is to use SF of equation (1) by simply substituting GC with the preprandial CGM measurement. However, it is also natural to think to improve BCs performance by exploiting CGM-provided information. 9
In the last years, some approaches to improve equation (1) by taking advantage of the “dynamic” information provided by CGM sensors, and in particular of the glucose rate of change (ROC), have been proposed. Specifically, Scheiner 10 and Pettus and Edelman 11 developed some empirical formulas, hereafter indicated by SC and PE, respectively, to modify the insulin bolus amount computed in equation (1) according to the ROC arrow value, that is, a graphical indication of the magnitude and the direction of glucose changing displayed in most of currently commercialized CGM devices. To the best of our knowledge, such methods were never compared in clinical trials. A possible strategy to assess, compare and possibly further develop these methods is to perform in silico clinical trials based on simulation models.12-20 In this context, a preliminary study by Marturano et al 21 evaluated these two methodologies in an in-silico, noise-free environment showing that, despite being on average more effective than the SF, their performance is strongly dependent on the specific preprandial condition in terms of BG level and ROC value. In addition, these methods did not perform effectively for all the subjects, but for a subset of the tested subjects a deterioration of glycemic control was observed. These results suggest that applying the same correction for ROC to equation (1) for all the preprandial BG conditions and in a way equal for all individuals can be somewhat simplistic. This calls for more sophisticated approaches able to optimize insulin BC according to the preprandial conditions and personalize the bolus calculation taking into account subject’s characteristics.
Given the complexity of the problem at hand, the nonlinear nature of glucose-insulin dynamics and the necessity of exploiting information coming from different domains, machine learning techniques, and in particular neural networks (NNs), appear a natural candidate to approach the problem of BC personalization. Indeed, an NN could be fed not only with features extracted from the CGM data stream, for example, the ROC information, but also other (easily accessible) therapy parameters, such as CR, CF, and the insulin pump basal rate, that implicitly reflect the individual patient physiology and have influence on the glycemic outcome during a meal.
Therefore, the purpose of this work is to develop an NN corrector, hereafter labeled as NNC, to determine how to correct the insulin bolus amount calculated with SF by exploiting the information on patient’s CHO intake, preprandial conditions and the aforementioned individual parameters. NNC is assessed versus SF, SC, and PE in silico, in a noise-free single meal study on 100 virtual subjects generated by using the UVa/Padova T1D Simulator 22 analyzed in different conditions in terms of preprandial BG, ROC and CHO intake.
Methods
Simulated Dataset
Data of 100 virtual adult subjects were generated by the UVa/Padova T1D Simulator. 22 Each subject was simulated several times in a single-meal scenario with different initial conditions, each defined by a different combination of meal CHO quantity and preprandial BG and ROC conditions. Simulation starts at 12:00 PM where a lunch of u = {50,60,70,80,90,100} g of carbohydrates (CHO) is located. The initial conditions in terms of preprandial BG and ROC were obtained in a separate simulation in which, by mean of a trial-and-error procedure, the time and amount of breakfast, morning snacks, and relative insulin boluses were manipulated to achieve the desired (BG, ROC) pair at meal time. For the sake of simplicity and practicality, ROC values at mealtime are discretized as follows:
As result, for each subject, we were able to obtain a total of 144 different meal conditions, that is, possible combinations of meal amount (50, 60, 70, 80, 90, 100), ROC values (–2, –1, 1, 2 mg/dL/min), and preprandial BG levels (60, 70, 80, 100, 150, 250 mg/dL). It is worthwhile remarking that we decided to not test scenarios where ROC = 0 since, by definition, SF, SC and PE results are the same. In addition, we also ignored the ROC = ±3 mg/dL/min case, since for some subjects it was impossible to be achieved with realistic manipulations of meal content and insulin dose of breakfast and morning snacks.
Literature Methodologies for CGM-Based Insulin Bolus Calculation
Both SC 10 and PE 11 methods integrate in equation (1) a correction employing a prediction of future BG by computing B as:
where
while, in PE it is defined as:
Notably, in all these two methods the ROC-based adjustment is equal for all individuals and for all preprandial BG level. A possible margin of improvement is to develop methods to determine a function
Determination of the “Optimal” Insulin Bolus Correction
Considering a specific patient p and meal condition m, that is, meal amount, preprandial BG and ROC values, we want to identify the “optimal”
The New NN-Based Insulin Bolus Calculator Formula
The chosen NNC structure is summarized in Figure 1a. It consists of a feedforward fully connected NN composed of three hidden layers. Network structure has been chosen through a preliminary investigation on the training set data, following the rationale of obtaining a compromise between capability of fitting the training data and ability to generalize. In addition, two dropout layers have been interposed between each hidden layer to prevent overfitting and improve the generalization capability of NNC.
24
For each dataset record, we build a record consisting of 10 patient-related characteristics, hereafter labeled as

(a) Structure of the proposed NNC neural network. (b) Scheme of the software framework implemented to tune NNC hyper-parameters h: block A randomly initializes h values and splits the dataset to defines test and training set; block B assesses the performance of h in a 5-fold CV setting over the training set; block C implements TPE to optimize h; block D selects the best h set and finally; block E evaluates the performance of NNC on the test set.
The NNC input layer consists of 10 neurons, each of which associated to a feature of
Training of NNC is performed through gradient descent RMSprop training algorithm
26
applied in a mini-batch mode. In particular, we build a software framework (schematized in Figure 1b) to solve two problems: first, we want to tune the NNC hyper-parameters and structure, second we want to automatize the model selection and training procedure. In detail, block A splits the abovementioned dataset to define training and test data, assigning 80% of the available (
Then, for a given set of hyper-parameters h, block B assesses its performance in a 5-fold cross-validation setting. In practice, the training set is divided into five folds, then four folds are used for training the NNC and the fifth one is used for validation and evaluation. Finally, block B computes the average intrafolds mean squared error (MSE) defined as:
where subscript h indicates the hyper-parameter set at hand and MSEk stands for the MSE computed by considering the k-th fold as validation set:
where
To solve the hyper-parameter optimization task, block C is iterated 100 times to implement the tree-structured Parzen estimator (TPE) technique,
27
that is, an optimization algorithm where new observation (a set of hyper-parameters) is collected and analyzed at the end of each iteration to decide which set of hyper-parameters will be tried next. Finally, in block D, we select the final set of hyper-parameters h by which we obtained the minimum
Assessment of Glycemic Outcome
For each test set scenario in
By mean of these comparisons we want to first verify both if NNC performs better than both the gold standard, that is, SF, and if it improves the performance of currently available methodologies for computing equation (3), that is, SC and PE. Moreover, comparing the estimated corrections,
Results
Representative Example
Figure 2 shows two examples of BG profiles obtained with the considered methods. In the top panel case (adult#26, Gc = 250, ROC = –1 and CHO = 100) the NNC achieves significantly better results compared to SF, SC and PE being able to avoid hypoglycemia. Moreover, comparing the glycemic outcomes obtained using equation (2) with OPT (

Example of BG trace obtained with SF (in blue), OPT (in red), NNC (in yellow), SC (in violet), and PE (in green) methods. X-axis have been truncated at 840 min since, thereafter, the BG traces coincides. Top panel. BG profiles obtained for the virtual subject adult#26 when Gc = 250, ROC = –1 and CHO = 100. Bottom panel. BG profiles obtained for the virtual subject adult#59 when Gc = 80, ROC = 2 and CHO = 80. Profiles has been zoomed in to highlight BG traces around minimum level.
Assessment of Methods in Terms of BGRI
In Figure 3, the distributions of the BGRI difference (ΔBGRI) between SF versus OPT, SF versus NNC and OPT versus NNC are shown via boxplot representation. Numerical values (median and interquartile range) are reported in the first three columns of Table 1. SF versus OPT distribution represents the best achievable improvement by mean of equation (3). In particular, using the optimal correction, we obtained a statistically significant (P < .001) median BGRI improvement of 0.40 (see Table 1).

Boxplot representation of the distribution of ΔBGRI obtained comparing (a) SF versus OPT, SF versus NNC, OPT versus NNC, SC versus NNC, and PE versus NNC. Red horizontal lines represent median, boxes mark interquartile ranges, dashed lines are the whiskers, red crosses indicate outliers. Black dots indicate statistical significant between-distributions differences.
Median [Interquartile Range] Results of ΔBGRI (First Row) Obtained Comparing SF Versus OPT, SF Versus NNC, OPT Versus NNC, SC Versus NNC and PE Versus NNC and P Values Obtained Using the Dunn’s Post Hoc Test (Second Row).
Focusing on SF versus NNC, as for SF versus OPT, the obtained results are better in NNC (see Table 1). Notably, the median ΔBGRI and interquartile range is almost the same as in SF versus OPT, meaning that the NNC estimates the optimal target values with good precision. As further proof of the capability of the NNC in estimating the optimal correction values and improving the glycemic outcomes, in Figure 3 we report the distribution of the difference between BGRI in OPT and NNC. No statistically significant difference between the two distributions is found (median difference equal to 0, P = .30). However, Figure 3 points out that, in several scenarios, the NNC error is relevant and, compared to SF, lead to worse BGRI values. In particular, BG control worsens when using NNC to estimate
Figure 3 shows the ΔBGRI distribution and median/interquartile results obtained comparing the NNC with SC and PE. Numerical values (median and interquartile range) are reported in the last two columns of Table 1. Overall, according to Figure 3, NNC introduces a small but statistical significant improvement (P < .001) equal to 0.23 and 0.20 if compared with SC and PE, respectively (see Table 1). However, as above, boxplots show that, in several scenarios, NNC lead to worse glycemic outcomes due to the error in the estimate of the optimal
Remark
The effectiveness of the optimal correction
Discussion and Conclusion
Use of CGM devices in T1D management opened new algorithmic challenges. 28 In particular, FDA approval of nonadjunctive use of CGM increased the interest toward methods to “correct” SF of BC to take into account the information on the glucose ROC. Both intuition and evidence provided by the in silico studies 21 suggest that the optimal modulation of insulin bolus is strongly related to preprandial conditions and individual parameters of the patient.
In this paper, we proposed a new NN-based methodology to personalize insulin bolus calculation exploiting GC, ROC, IOB, CR, CF, Ib, GT, BW, VC, and CHO. An in silico study performed in 100 virtual subjects in noise-free conditions, showed that, in terms of glycemic outcomes measured as BGRI over 24 hours, the new method outperforms the literature approaches SF, SC, and PE, and is close to the optimum determined by exhaustive search. Although, quantitatively improvements might seem minor, these preliminary results encourage further investigations on machine learning-based methodologies to provide patients with decision support tools able to ease their daily insulin therapy routine. With regard to this aspect, it is important to stress that, in the present investigation of tools to predict the optimal correction of SF, we limited ourselves to evaluating NNs. Of course, other nonlinear machine learning techniques (eg, kernel support vector machines or regression trees) could be considered for the scope as well. Implementation of alternative methods will be matter of future investigations, together with a comprehensive analysis of the relative performance of the so-obtained calculators. In particular, a margin of improvement emerged from the Remark 1 reported in the Results lies in relaxing the strict constraints related to the original structure of SF by devising new methods to compute directly the optimal insulin bolus. Work presently underway at our lab concerns the development of machine learning techniques capable to “learn” new optimal dosing rules using the information provided by CGM devices.
To conclude, future work will also involve testing the NNC on more challenging scenarios by means of the T1D patient decision simulator of Vettoretti et al, 29 which expands the model employed in the UVA/Padova T1D Simulator by new modules describing error of glucose monitoring sensors (both self-monitoring of blood glucose 29 and CGM 30 ) and patient behavior. In addition, another interesting aspect would be furtherly exploring both the NNC structure by reducing the number of nodes in the middle layer and introducing fuzzification as a way to accommodate person-to-person variation and expanding the feature set we used to train NNC. For example, it will be worth adding as inputs also a preprandial window of CGM values to exploit fully the information on BG dynamic provided by CGM devices. Finally, it would be also interesting to investigate how the NNC performance is influenced by the variability of CGM sensor accuracy, for example, observed for different days of sensor wear or different number of sensor’s calibrations per day.31-34
Footnotes
Abbreviations
B, computed insulin bolus; BC, bolus calculator; BG, blood glucose; BGRI, blood glucose risk index; BW, body weight; CF, correction factor; CHO, carbohydrate; CR, carbohydrate-to-insulin ratio; GC, current blood glucose level; GT, target blood glucose level; Ib, insulin pump basal infusion ratio; IOB, insulin on board; MSE, mean squared error; NNC, neural network model; OPT, optimal bolus calculator; PE, Pettus and Edelman method; ROC, rate of change; SC, Scheiner method; SF, standard formula for bolus calculator (see (1)); SMBG, self-monitoring of blood glucose; T1D, type 1 diabetes; TPE, tree-structured Parzen estimator; VC, insulin sensitivity variability class.
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
