Predicting and monitoring blood glucose through nutritional factors in type 1 diabetes by artificial neural networks

The monitoring and management of Postprandial Glucose Response (PGR), by administering an insulin bolus before meals, is a crucial issue in Type 1 Diabetes (T1D) patients. Artificial Pancreas (AP), which combines autonomous insulin delivery and blood glucose sensor, is a promising solution; nevertheless, it still requires input from patients about meal carbohydrate intake for bolus administration. This is due to the limited knowledge of the factors that influence PGR. Even though meal carbohydrates are regarded as the major factor influencing PGR, medical experience suggests that other nutritional should be considered. To address this issue, in this work, we propose a Machine Learning (ML)-based approach for a more comprehensive analysis of the impact of nutritional factors (i.e., carbohydrates, protein, lipids, fiber, and energy intake) on the blood glucose levels (BGLs). In particular, the proposed ML-model takes into account BGLs, insulin doses, and nutritional factors in T1D patients to predict BGLs in 60-minute time windows after a meal. A Feed-Forward Neural Network was fed with different combinations of BGLs, insulin, and nutritional factors, providing a predicted glycaemia curve as output. The validity of the proposed system was demonstrated through tests on public data and on self-produced data, adopting intra-and inter-subject approach. Results anticipate that patient-specific data about nutritional factors of a meal have a major role in the prediction of postprandial BGLs.


INTRODUCTION
Type 1 Diabetes (T1D) is an autoimmune condition in which the immune system attacks and destroys the pancreatic cells (β cells) that produce insulin [1]. Recent epidemiological research (e.g., [2], [3]) estimate that the T1D worldwide prevalence is 9.5 per ten thousand people.
Along with regular exogenous insulin injection, T1D patients have to lead a healthy lifestyle and carefully manage the levels of blood sugar to prevent complications, such as hypoglycaemia and hyperglycaemia [4]. In particular, the management of the postprandial glucose response is a major issue for T1D patients [5].
The technological advantages in healthcare and the progress in wearable devices [6], [7] have led to the development of Artificial Pancreas (AP) [8], a closed-loop systems that combines a Continuous Glucose Monitoring (CGM) and, a control algorithm based on heuristics and theoretical knowledge, automating the insulin release via an insulin pump [9]. While the ideal goal is to design a fully closed-loop system, actual clinical scenarios depend on several physiological factors, e.g., delays in insulin assimilation. At the present time, only Hybrid Closed-Loop Systems (HCLSs) are available for medical practice. Although basal insulin is automatically delivered with little to no issue, these systems are unable to adequately manage the postprandial response, so the patient is forced to manually set up the pre-prandial dose of insulin [10]. Thus, a crucial part of HCLS devices consists of the algorithm responsible of maintaining the levels of blood glucose in a safety range. Several control strategies have been designed and presented in literature, spanning from proportional-integral-derivative control to fuzzy logic control [11]. Nonetheless, the Postprandial Glucose Response (PGR) still remains a main open issue in APs [12]. Research on this topic focused mostly on carbohydrates' intakes, ignoring additional aspects relative to mealtime, such as other nutritional factors (lipids, proteins, etc.) or psycho-physiological status [13], [14]. Artificial Intelligence (AI), and in particular Machine Learning (ML), is increasingly providing new opportunities in AP designs by boosting the extraction of information from big biological data [15]- [17]. An example of promising AI-based strategies for AP is offered by Artificial Neural Networks (ANNs), which aim to early detect hypo-and hyper-glycaemia events, and to consequently enhance insulin administration [18].
However, it is worth pointing out that, at the state of the art, even these ANNs models considered mostly carbohydrates, without taking into account other nutritional factors [19]. As a matter of fact, the nutritional properties of meals can impact Blood Glucose Level (BGL), significantly affecting PGR. For instance, clinical trials have demonstrated that high-fat/protein meals require more insulin than lower-fat/protein meals with identical carbohydrate content. Hence, the design of models based on meal composition rather than just carbohydrates intake seems significant [20].
Starting from these considerations, a study of the impact of nutritional factors over the 60 minutes (min) after a meal was conducted by ML methods. In particular, the effect of nutritional factors such as carbohydrates, proteins, lipids, fibres, and meal energy intake, on postprandial blood glucose response was analysed. Relying on models presented in [21] and [22], we proposed a model able to predict the glycaemic curve over the 60 minutes from the meal, by considering the nutritional factors. More in detail, the impact of the nutritional factors was investigated by feeding the model with a different combination of BGLs, insulin doses, and nutritional factors, by validating the model on both public and self-produced data.
The paper is organised as follows. In section 2 an overview of the state-of-the-art of ML solutions in the managing of postprandial (after the meal) blood glucose response was presented. In section 3 the datasets employed, and the proposed method were described. The experimental setup is reported in section 4. Section 5 and section 6 show results and discussion, respectively. Finally, in the concluding section the key points of the work are summarised, and the future steps are outlined.

RELATED WORK
ML has gained increasing attention in several research fields, and especially in health-related tasks [23]- [27]. Among the ML techniques, the use of ANNs in prediction of blood glucose was investigated in several studies [28]- [35], using data from real T1D patients and virtual patients [36], as those obtained with UVA/Padova simulator [37]. This tool allows the generation of virtual subjects through complex physiological models, enabling users to control the experimental parameters. Nonetheless, due to the difficulty of tuning its elements and interpreting the results, actual data from real patients are sometimes preferred for the examination of specific realistic scenarios.
As example, in [33] the authors analysed the performance of a Feed-Forward Neural Network (FFNN) model for real-time prediction of glucose implementing a prediction horizon (PH) of 75 min. The FFNN was trained using a training set that included CGM values collected in 17 patients. Overall, the reported rootmean-square deviation (RMSE) was (43.9 ± 6.5) mg/dL.
In [34], a glucose prediction algorithm that combines CGM readings and information on carbohydrate intake was proposed, by testing both on virtual patients, and real datasets. Results on simulated and real data showed that for a prediction horizon (PH) of 30 min, RMSE was calculated as (14.0 ± 4.1) mg/dl and (9.4 ± 1.5) mg/dl, respectively.
In [35], a multilayer convolutional neural network (CNN) followed by a recurrent neural network with long short-term memory (LSTM) cells was investigated for the prediction of blood glucose with PHs of 30 and 60 min. The study was conducted on both virtual patients and T1D real patients with CGM sensors, by achieving RMSE results of (21.07 ± 2.35) mg/dl (PH = 30 min) and (33.27 ± 4.79) mg/dl (PH = 60 min) for real data.
Recently, some studies considered the nutritional factors of the meal as an important input of the neural networks [22], [38], [39], forecasting the glycaemia values after the meal. In this regard, in [22] a FFNN to predict post-prandial blood glucose values every 2 min up to 4 hours was designed, by using as input meal information in two ways. In the former, raw nutrient quantities were used. Hence, the network was fed by carbohydrates (g), lipids (g), fibers (g), insulin amount (pmol/1000) and BGL (mmol/l). In the second way, a bioinspired model of glucose absorption curve. In particular, numerical parameters such as time elapsed to the peak of the curve, time elapsed to 50 % of the peak of the curve, and rate of absorption at the maximum of the curve were calculated. Then, these curve characteristics were exploited to train the network along with insulin amount and BGL. They showed that better performance was achieved when the absorption model was integrated in the model, with an average RMSE of 1.12 mmol/L (PH = 60 min), compared to the RMSE value for the first approach (1.816 mmol/L). Nevertheless, among the involved subjects, only one was a T1D patient.
It is worth to note that previous reported studies do not focus on the impact of nutritional factors in blood glucose prediction. Considering this, a study of the impact of nutritional factors over a 60-min time window after the meal was conducted by ML methods.

Dataset
DirecNet dataset -The DirecNet is a public dataset of CGM measurements, collected by Jaeb Center for Health Research [40]. It includes data from child-patients with T1D wearing the Medtronic MiniMed Guardian-RT, a HCLS device that recorded glucose values at intervals of 5 min. The dataset contains CGM data from 50 patients, aged between 3 to 7 or 12 to 18 years, with a T1D for more than 1 year. For approximately 7 days, the blood glucose data was continually collected every 5 minutes.
AI4PG dataset -The AI4PG dataset, provided by Federico II University Hospital (Naples, Italy), includes information from 25 T1D patients wearing the HCLS, Medtronic MiniMed 670G system [41]. The dataset reports data on meals, insulin doses, and CGM measurements for 6/7 days. Subjects range age was (40 ± 12) years with a duration of diabetes of (15 ± 12) years. Patients completed food diaries with information about meals for 7-days, by obtaining a dataset of 1264 meals (breakfasts, lunches, dinners) represented as time series of pre-and postprandial glycaemic levels (mg/dL). The dataset includes details about the Manual Boluses (MBs) administered at mealtime based on carbohydrate intake of the meal, and an estimate of carbohydrates (g), lipids (g), proteins (g), fibers (g) and energy intake (kcal) associated with each meal. The glycaemia levels from CGM every 5 min, from 30 min before meal to 60 min after meal was reported. The data were collected with informed consent from eligible subjects and the protocol was approved by the Ethical Committee of Federico II University.

Proposed Method
The proposal of this study is the prediction of post-prandial glycaemia in T1D patients over one hour after the meal, using a FFNN model [42]. The taken approach was inspired by the findings reported in [21] and [22], choosing as inputs a 30-min window of blood glucose values and 8 associated statistical features. More in detail, minimum, maximum, mean, standard deviation, pick-to-pick difference, median, kurtosis, and skewness were calculated on the glycaemia values. The output is the entire glycaemic curve from 5 min to 60 min after the meal, and namely 12 output neurons correspond to these values sampled every 5 minutes. Prediction performance was then evaluated on all the 12 output values simultaneously. The number of hidden layers and neurons of the FFNN was set by a grid search strategy. To evaluate the performance of the proposed system in predicting blood glucose levels, a preliminary experiment using DirecNet data was conducted. Subsequentially, the system was applied to the self-produced AI4PG dataset. Since the goal was to examine how nutritional parameters affected postprandial glycaemic response, nine different input configurations were tested: • #1 Only glycaemia: the model took in input: -blood glucose levels (mg/dL) from 30 min before meal until mealtime every 5 min -glycaemia's statistical features such as minimum, maximum, mean, standard deviation, difference between highest and lowest, median, kurtosis, and skewness calculated on glycaemia values mentioned above. • #2 Insulin, no nutritional factor: in addition to glycaemia values and associated statistics, the network also took as input the insulin bolus MB (mmol/L). • Single-nutritional factors scenarios: in these scenarios, the inputs were composed of glycaemia values, statistical features, MB, and a single nutritional factor across the following: -#3 Carbohydrates (g), - #4 Proteins (g), - #5 Fibers (g), - #6 Lipids (g), and -#7 Energy intake (kcal) associated with each meal. Root Mean Square Error (RMSE), defined by equation (1), was used to evaluate the prediction performance.
where and represents the measured and predicted BGLs at the same instant of time, respectively; is the time, while is the total number of blood glucose measurements in the dataset.

EXPERIMENTS
This section describes the conducted experiments, by reporting the pre-processing and the experimental setup. A set of preliminary experiments were carried out by using the public dataset DirecNet to validate the proposed ML system in the BGL prediction task. Then, as the goal of this study was analysing the impact of nutritional factors on the BGL prediction capability, the system was used on the AI4PG dataset. Figure 1 illustrates the key steps of the proposed pipeline, which are detailed below. Figure 1. Proposed pipeline. The data pre-processing stage includes the Savitzky-Golay filtering step and statistical features calculation. Then, the dataset is split into training, validation, and test set, and scaled using the min-max scaler strategy. Model hyperparameters are tuned by a grid search strategy. Finally, the best model is selected.

3.1.
Pre-processing For both public DirecNet and self-produced AI4PG data, the pre-processing procedure involved filtering and scaling the data.
More in detail, from DirecNet dataset, the CGM data (mg/dL) of the 12 patients were considered. Based on [43], [44], to clean the data from noise and thus improve the performance, the data was filtered with Savitzky-Golay technique [45], by considering a first-order polynomial with a 15-step filtering window on BGLs. Then, the model input was constructed by using a 30-minute sliding window across the blood glucose data. Moreover, as mentioned, statistical attributes were calculated on each window of BGLs data and added as inputs: minimum, maximum, mean, standard deviation, difference between highest and lowest values, median, kurtosis and skewness.
As for the self-produced AI4PG data, we considered the blood glucose values (mg/dL), the MB (mmol/L), and the nutritional factors such as energy intake (kcal) of the meal, protein (g), carbohydrates (g), lipids (g), and fibers (g). Data from 15 patients were used, for a total 1036 meal records. Subsequentially, the BGLs were pre-processed by Savitzky-Golay filter using a first-order polynomial and a 15-step filtering window. Therefore, the input of FFNN was composed by glycaemic values from 30 min before meal until mealtime every 5 minutes. In other words, 7 blood glucose values are given in parallel as inputs to the model. In addition, as previously discussed, the 8 statistics computed on pre-prandial BGLs were used as input.

Experimental setup
A Feed Forward Neural Network (FFNN) was investigated as a predictor of postprandial blood glucose levels over a 60-min time window from the meal. In order to set optimal hyperparameters for the proposed FFNN model, a grid search strategy was implemented by considering the search spaces reported in Table 1. In particular, discrete ranges of values were chosen for the number of hidden layers (from 1 to 3), the number of neurons per layer (as powers of two) and the learning rate of the process. These values fall within reasonable ranges adopted in previous studies. Regardless of each single configuration, ReLU activation function [46] was chosen for each hidden layer, the regularization term (L2 penalty) with weight decay parameter was set to 0.0001, Stochastic Gradient Descent (SGD) [47] was used as optimization algorithm. The epochs were set to a maximum of 1000 with a patience of 20 [42]. For the experiments, we exploited intra-subjective and inter-subjective approaches on both DirecNet and AI4PG data. The intrasubjective approach relies on the inherent physiological variability among different individuals, examining one patient's data at a time and conducting a customized investigation to obtain more accurate considerations. Conversely, in the intersubject approach, data from all patients are pooled together to achieve more universal findings.
More in detail, for intra-subjective approach, a different model for each patient was built. To validate the method, a holdout validation strategy was performed by splitting the dataset into training, validation, testing sets. In particular, the training set contained 70 % of the data, the 10 % of data was used for validation, and the 20 % for testing. All data were scaled using min-max scaling, by computing the minimum and maximum of the training data. Instead, for the inter-subjective case, the data of all patients was used to build a single model to investigate the possibility that a model trained on data from a different subject can generalize to new data. To validate the method, a 5-fold cross-validation (CV) was performed. CV is a technique used in ML to better evaluate the performance of a predictive model on a limited dataset [47]. Generally, in k-fold CV, data are divided into k equal-sized folds. The model is trained on k-1 of these folds and evaluated on the remaining fold. This process is repeated k times and then the performance is averaged across all k folds. In this work, for each of the 5 iterations, a portion of the training data was used as the validation set, according to a 70 %/10 % splitting. A min-max scaler was applied considering the minimum and maximum values of the training data.
RMSE was used for model evaluation on the test set.

RESULTS
In this section, the experimental results both for intra-and inter-subjective approaches were reported.
DirecNet dataset -RMSE between actual and predicted values every 5 minutes over a 60-min time window was calculated and mean and standard deviation were reported in Table 2. In this case, the predictions were based only on BGL, as no information about insulin doses and meals is available. In the intra-subjective approach, the RMSE is the average on all the considered patients, whereas, in the inter-subjective case, the RMSE is the average on the 5-fold. As observed, the results are similar in the two approaches with a main difference in the standard deviation, that in the intra-subject case is greater due to high performance variability across different patients. Instead, since each fold contains data from different patients, the variability of performance between folds was minimal in the inter-subject case.
AI4PG dataset -In order to evaluate the impact of nutritional factors and insulin doses on BGL prediction, a statistical paired t-test, with significant level α of 0.05, was exploited. In particular, the t-test was used to compare the #1 Only glycaemia results with the other ones. The statistical significance was interpreted through p-value.
As can be seen from the results reported in Table 3, a positive statistical significance was obtained when the FFNN was fed by nutritional factors individually considered. As expected, carbohydrates are the factor that has the greatest impact on blood glucose prediction [48] in the first 60 minutes after the meal, but also other factors such as proteins, fibers, lipids, and the energy played a key role. Instead, for inter-subjective approach shown in Table 4, no statistical significance was found as a p-value always greater than the significant level α, reflecting the need to model interindividual variability. As a matter of fact, clinical studies showed a significant role of the individual characteristics in postprandial glucose [49].  Table 2. Mean RMSE with standard deviation for BGL prediction in intrasubjective and inter-subjective approach on DirecNet dataset.

DISCUSSION
The goal of this study was to investigate the influence of nutritional factors on BGL forecasts.
To do this, a set of preliminary experiments on a DirecNet public dataset allowed to verify the capability of proposed MLmodel in BGLs prediction with respect to the literature. However, in literature studies the role of nutritional factors, which could help to achieve more effective BGL predictors, is not widely investigated.
This study showed, for the intra-subjective case on AI4PG data, that not only carbohydrates but also other nutritional factors such as protein, lipids, fibers, and the caloric intake of the meal have an impact on the prediction of BGL over a 60min time window after a meal.
It is interesting to note that considering all the nutritional factors simultaneously leads to a lower effect on the performance with respect to the use of just one nutritional factor. This could be due to the Peaking Phenomenon [42], [50] of the proposed model, according to which, for finite training sets, the performance of a model does not improve as the increasing of the features number (in this case nutritional factors). Another reason could be a negative interaction between the nutritional factors involved.
Instead, for the inter-subjective case, the nutritional factors do not contribute to appreciably improved BGL predictions. Thus, the postprandial glycaemic response seems strongly related to individual subject characteristics and this agrees with clinical studies [48], [49], [51] that have demonstrated a postprandial glucose response almost constant in the same subject, while it changes among different subjects.
Hence, a better knowledge of how nutritional factors affect BGL prediction could enhance the algorithms controlling insulin infusion in HCLS and the calculation of insulin bolus.

CONCLUSIONS
The goal of this study was to explore how nutritional factors may affect the prediction of post-prandial BGL in the 60 minutes after mealtime, via machine learning methods.
A set of experiments to test BGLs prediction by a Feed Forward Neural Network was conducted on the self-collected AI4PG dataset, which also contained various data of interest like insulin doses and intakes of nutritional factors. First, the model was validated on the public DirecNet dataset, demonstrating capability to be able to obtain an acceptable prediction performance over a 60-minute time window. Then, a prediction performance analysis was computed on the AI4PG dataset, considering different nutritional factors as inputs to evaluate the impact of each of them. Finally, the case in which all the nutritional factors are considered simultaneously as input was explored.
The obtained results show that nutritional factor information can be relevant in BGL forecasts, but this information should be employed in a subject-specific fashion. Clearly, this does not exclude the possibility of exploring into alternative machine learning strategies based on transferring knowledge across different datasets, such as Transfer Learning techniques (e.g. [52], [53]).
This study focused on the impact on BGL predictions of different nutritional factors in a 60-minute time window after a meal. In addition to the global RMSE performance, one could also evaluate the performance on different time horizons. For instance, this was already investigated in [54], though the temporal resolution was coarser (15 minutes in spite of 5 minutes). In this framework, one could also investigate the impact of nutritional factors at different time scales (greater than 60 minutes). Moreover, eXplainable Artificial Intelligence (XAI) [55]- [59] methods could be help in explaining the input-output relationships and so the impact of different scenarios on BGL prediction. Finally, using more sophisticated neural network models, like Long Short-Term Memory, could improve the outcome. Table 3. Experimental results in intra-subjective approach on AI4PG dataset. The t-test p-values between the #1 Only glycaemia scenario and the other ones are also reported. In bold the p-values less than the significance level α.