Abstract
Aims:
For people with type 2 diabetes treated with basal insulin, suboptimal glycemic control due to clinical inertia is a common issue. Determining the optimal basal insulin dose can be difficult, as it varies between individuals. Thus, insulin titration can be slow and cautious which may lead to treatment fatigue and non-adherence. A model that predicts changes in fasting blood glucose (FBG) after adjusting basal insulin dose may lead to more optimal titration, reducing some of these challenges.
Objective:
To predict the change in FBG following adjustment of basal insulin in people with type 2 diabetes using a machine learning framework.
Methods:
A multiple linear regression model was developed based on 786 adults with type 2 diabetes. Data were divided into training (80%) and testing (20%) sets using a ranking approach. Forward feature selection and fivefold cross-validation were used to select features.
Results:
Participants had a mean age of approximately 59 years, a mean duration of diabetes of 12 years, and a mean HbA1c at screening of 65 mmol/mol (8.1%). Chosen features were FBG at week 2, basal insulin dose adjustment from week 2 to 7, trial site, hemoglobin level, and alkaline phosphatase level. The model achieved a relative absolute error of 0.67, a Pearson correlation coefficient of 0.74, and a coefficient of determination of 0.55.
Conclusions:
A model using FBG, insulin doses, and blood samples can predict a five-week change in FBG after adjusting the basal insulin dose in people with type 2 diabetes. Implementation of such a model can potentially help optimize titration and improve glycemic control.
Keywords
Introduction
Suboptimal glycemic control among people with type 2 diabetes treated with basal insulin is a well-known and documented issue leading to persistent periods of hyperglycemia increasing the risk of severe micro- and macrovascular complications (e.g., blindness and cardiovascular diseases).1-4,5 The reasons for suboptimal glycemic control are manifold and often caused by clinical inertia-induced behavior among people with type 2 diabetes and clinicians. 1 Furthermore, finding the optimal basal insulin dose, referred to as insulin titration, is complicated, as the optimal dose differs from person to person.6,7 The individual optimal dose will, moreover, likely change over time due to variations in pancreatic insulin secretion, insulin sensitivity, lifestyle changes, stress levels, and so on.1,3,7,8 Hence, identifying the optimal basal insulin dose is a pursuit that requires time and experience from clinicians together with patience and understanding from the person with type 2 diabetes undergoing the treatment.1,2,6,9 These circumstances can lead to prolonged and conservative titration, potentially causing treatment fatigue and non-adherence among people with type 2 diabetes leading to suboptimal glycemic control despite the well-established efficiency of treatment with basal insulin from clinical trials.2,6,9
Prior work has mainly focused on paper-based titration algorithms similar to the standard of care in outpatient and telemonitoring settings. 10 A number of studies have also investigated the effect of utilizing apps and other digital devices in regard to basal insulin titration.11-14 A few studies have explored mathematical models’ abilities within basal insulin titration in people with type 2 diabetes. These studies have mainly focused on utilizing control theory methods.8,15,16 A recent study by Chen et al 17 investigated machine learning approaches’ capabilities in basal insulin titration. To the knowledge of the authors of this work, this is the first study to utilize machine learning methods for basal insulin titration in people with type 2 diabetes. The study investigated six machine learning methods’ ability to predict the prescribed basal insulin dose based on data from electronic health records of 819 people with type 2 diabetes which showed promising results. 17 However, it remains unclear whether the insulin dose prescribed was optimal for the subjects since the results reported by Chen et al 17 offer limited insights into the glycemic control of the 819 people with type 2 diabetes upon which the models were developed. A model able to foresee the effect of a specific basal insulin dose on the fasting blood glucose (FBG) in people with type 2 diabetes during a typical titration period may ease some of the challenges related to titration. This could help identify the optimal basal insulin dose timelier by enabling more efficient and personalized titration. Thus, this study aimed to develop a model able to predict the effect of a change in basal insulin dose on FBG in people with type 2 diabetes using a machine learning framework.
Methods
Data Source
The data used to develop the present machine learning model originated from a 26-week clinical trial (ClinicalTrials.gov: NCT01819129) which investigated the efficacy and safety of fast-acting insulin aspart compared with insulin aspart in adults (>18 years) with type 2 diabetes treated with insulin glargine and metformin. 18 Other antidiabetic treatment was disconnected. Before randomization eligible subjects underwent a 7-week run-in period where insulin glargine was actively titrated according to a standard of care titration scheme to the target of 72.0 to 90.0 mg/dL. Subjects enrolled in the study had an HbA1c of 53 to 80 mmol/mol (7.0%-9.5%) at screening. Only data collected during the run-in period were used to develop the prediction model since participants were only treated with basal insulin analogs combined with metformin in this period.
Demographic information and blood and urine samples were collected at the screening visit. These were used as potential features in the machine learning model (see Table 1). During the run-in period, self-reported FBG was measured with a glucometer, and self-reported basal insulin doses were collected on three consecutive days each week. Although the clinical trial provided a glucometer that was factory-calibrated to plasma glucose values, there are still concerns about the accuracy of the glucose measurements due to their self-reported nature. 18 However, it is worth noting that efforts were made to address these concerns by providing standardized equipment. Self-reported FBG was used to titrate participants’ insulin doses weekly. Furthermore, self-reported hypoglycemic events were collected.
Features Extracted From the Data.
Abbreviation: FBG, fasting blood glucose.
Feature Extraction
The first step in the machine learning framework was to extract relevant features. The run-in period was split into an observation and a prediction window (see Figure 1). The first week of the run-in period was allocated to extract features that could give insights into the participants’ insulin sensitivity and pancreatic insulin production since c-peptide and similar tests were unavailable from the blood samples. Therefore, the prediction time was the beginning of the second week of the run-in period with a prediction window of approximately five weeks.

Splitting of data into an observation window from where features were extracted and a prediction window which marks the time between prediction time and prediction target. The numbers 1 to 7 represent the days of the week.
The prediction target was the change in self-reported FBG from week 2 to 7. An overview of all features extracted from the data is seen in Table 1.
In total, 41 features were extracted and formed the pool of potential input variables for the prediction model.
Preprocessing of Data
The second step in the machine learning framework was to preprocess the data before model development. First, categorical features were encoded, so a numeric number represented different levels in the categorical features. Nominal categorical features (sex, race, and trial site) were hot one encoded, whereas ordinal categorical features (ketones in urine, protein in urine, and erythrocyte sedimentation rate in urine) were ordinal encoded. Second, data points below or above the limit of detection in collected blood and urine samples were handled using single imputation. Data points below the limit were replaced with the limit minus one and those above the limit were replaced with the limit plus one. Third, features with >20% missing data were excluded and after that participants with missing data were excluded (see Figure 2).

The sorting of participants and features that occurred during preprocessing of the data prior to model development. n refers to the number of participants, and m refers to the number of features.
Finally, data were divided into 80% for model training and 20% for model testing stratified based on the change in FBG using a ranking approach (see Figure 3). The training data set was normalized before model development.

The ranked approach to stratify participants into training and test data sets and create five subsets for cross-validation. The gradient of the blue color indicated the degree of change in fasting blood glucose from weeks 2 to 7 for the participants. The lighter the color, the more positive change, and the darker the color, the more negative.
Model Training and Validation
The third step of the machine learning framework was to train and validate a model. Using forward selection, fivefold cross-validation was used to select the most informative features while training a multiple linear regression model optimized on relative absolute error (RAE). The addition of features was continued until the model performance converged. Python version 3.8.8 was used to develop the model. An illustration of the process of training the prediction model is seen in Figure 4.

The combined feature selection and model training process. In step 1, all features are tested separately, and the feature resulting in the lowest average relative absolute error (RAE) is selected. In step 2, the remaining features are tested in combination with selected features and added to the pool of selected features if a reduction in average RAE is seen. This process continues until performance converges. In step 3, a multiple linear regression model is trained on all selected features using fivefold cross-validation.
To validate the performance of the developed prediction model, the mean of RAE, mean of Pearson correlation coefficient (r) with associated two-sided P value, and coefficient of determination (R2) across the validation folds in the fivefold cross-validation were reported together with confidence intervals. Furthermore, a scatterplot of observed versus predicted data points for the training data set was constructed using the validation folds in the fivefold cross-validation. As part of the results, the model equation with normalized beta coefficients, representing the impact of a one-unit increase of a feature on the mean change in FBG when the remaining features are fixed, was computed.
Test of the Model
The prediction model was tested using the allocated test data set to determine the model’s performance. RAE, r with associated two-sided P value, and R2 were reported. A scatterplot of observed versus predicted data points for the test data set was also constructed.
Results
Table 2 shows the baseline characteristics of the 786 participants divided into training and test data sets. The participants had a mean age of approximately 59 years, a mean duration of diabetes of 12 years, and a mean HbA1c at screening of 65 mmol/mol (8.1%) in both data sets. Thus, no apparent difference between the participants in the training and test data set was seen from visual inspection of Table 2.
Baseline Characteristics of Participants in the Training and Test Data Sets.
Abbreviation: FBG, fasting blood glucose.
Five features were selected based on the forward selection: FBG at week 2, total change in basal insulin dose, trial site, hemoglobin level in blood at screening, and alkaline phosphatase level in serum at screening. Training the machine learning-enabled model resulted in the following model equation:
Table 3 shows the result of validation and test of the model and Figure 5 shows the observed versus predicted change in FBG obtained during validation and test of the model, revealing a similar trend along the diagonal line (y=x). Thus, no apparent signs of overfitting..
Results of Validation and Test of the Development Model on Training and Test Data Sets, Respectively.
Abbreviations: CI, confidence interval; REA, relative absolute error.
P < .001.

Observed versus predicted change in fasting blood glucose obtained during validation and test of the present model.
Discussion
The present study demonstrated that it is feasible to predict the effect of a change in basal insulin dose on the FBG in people with type 2 diabetes using a machine learning-enabled linear model.
Other than the study by Chen et al, 17 utilization of a machine learning approach has to the best of our knowledge not been investigated in regard to basal insulin titration in people with type 2 diabetes. The results both from Chen et al 17 and the present study elucidate the potential of models developed using a machine learning approach to optimize insulin titration in type 2 diabetes. Of the five features selected as input to the present model, two aligned with Features selected by models in Chen et al. 17 : FBG level when the adjustment of insulin dose was made and size of the dose adjustment. The remaining three features selected by the present model were not available in the study by Chen et al. 17 The selection of trial site as a feature could indicate some variations in the titration across different trial sites. A model including a trial site would be difficult to implement in a real-world setting as it would require the model to be retrained and when implemented at a new site or calibrated to each site. Investigating why trial site was selected and considering the best way to include that information for the purpose of future implementation is thus relevant to investigate and consider. At first glance, the two selected blood samples’ hemoglobin level, and alkaline phosphatase level may not seem related to glycemic control. However, both have been found to be correlated to diabetes-relevant factors which could explain the selection of these two blood samples. Hemoglobin level has been found to be positively correlated with insulin resistance in different types of tissue in people with diabetes, while abnormal hemoglobin levels mayindicate kidney or renal disfunction.19-21 Elevated alkaline phosphatase levels have been indicated as a marker of nonalcoholic fatty liver disease, which also affects insulin resistance and hepatic glucose production.22-24 Therefore, the two blood samples may give the model valuable insights into the participants’ disease complexity. This elucidates the need to include blood samples and information that directly reflect participants’ disease complexity such as c-peptide and whether diabetic complications are present in future work since such information seems to improve the model’s performance.
Machine learning approaches have been more widely applied to optimizing insulin doses within the area of type 1 diabetes where the focus has been optimization of bolus insulin doses, 25 insulin infusion rates,26,27 or short-term prediction of glucose levels aimed as input to automated insulin delivery to optimize dosing advise.28-30 Results from these studies further support the evidence that machine learning approaches can be utilized in optimizing insulin treatment. However, results from type 1 diabetes are not directly transferableto people with type 2 diabetes. Therefore, further research in utilizing machine learning to optimize basal insulin titration of people with type 2 diabetes is needed to explore the potential.
The present model’s performance showed a lack of ability to correctly predict positive changes in FBG following a change in insulin dose. This is evident based on inspection of Figure 3 where it is seen that observed positive changes in FBG are mainly predicted as changes of 0 mg/dL or less by the model. This could point to the fact that the model may not be able to capture patterns in the data resulting in a positive change in FBG. This could result from the lack of information on disease progression in the individual participant (e.g., pancreatic insulin production and insulin resistance). Despite the efforts to include such indicators as potential features through extracting knowledge about changes in insulin doses and FBG from week 1 to 2, this information might not give sufficient insights into pancreatic insulin production or insulin resistance. Moreover, the inability to correctly predict positive changes in FBG could also result from too narrow a distribution of changes in FBG represented in the data since most participants experience a negative change in FBG during the titration period. Finally, factors such as BMI, change in lifestyle, stress level, sickness, and so on that are known to also impact glycemic control were not included in this analysis due to the lack of availability which may impact the model’s performance negatively.31,32 However, this information is often difficult to obtain and challenging to implement, as it is rarely routinely collected. Thus, increasing the number of participants in the data set upon which the model is developed and including information about pancreatic insulin production, insulin sensitivity, and other factors known to affect glycemic control such as BMI, change in lifestyle, and etc. could improve the performance and generalizability of the model.
The study was limited since both FBG and insulin doses were self-reported and, therefore, prone to issues with validity.33,34 Especially insulin doses taken by people with type 2 diabetes are likely noise-prone.35,36 As non-adherence is a common problem within type 2 diabetes, there are most likely mismatches between the self-reported doses and the doses taken by the participants. 33 This might have blurred the effect of changes in insulin dose on FBG since some of the reported doses might not have been what the participants took. Therefore, developing the model using insulin data collected by smart insulin pens to give more accurate information on the insulin doses affecting the FBG could be of interest. In the same line of thought, using continuous glucose monitors to capture FBG could also improve the validity of the FBG data.
A model able to predict the effect of a change in basal insulin dose on FBG in people with type 2 diabetes could be used as a decision-support tool for clinicians when titrating insulin. Thus, it is visible to clinicians which patients react promptly to changes in insulin dose and which patients require more extensive changes to gain the wanted change in FBG. Previous studies have mainly investigated the use of different approaches (e.g., digital devices, telemonitoring, etc.) for adjusting basal insulin in individuals with type 2 diabetes by recommending a specific insulin dose.11-14 By flipping the titration algorithm and predicting the expected impact on FBG rather than the insulin dose, clinicians gain valuable knowledge on how a particular individual will respond to changes in insulin. This personalized insight enables tailored treatment adjustments to meet individualized FBG targets. However, practical factors must be considered before implementation of such a model. More refinement and thorough testing are necessary before implementation in a real-world setting as the model, at the current stage, cannot account for e.g., the use of different basal insulin with varying action profiles and concomitant medication. In a real-world setting, patients will receive various combinations of medications and different types of basal insulin which effect glycemic control differently. Thus, a titration model must also consider such factors if it is to be used in a real-world setting. This work is not at a stage of maturity where it is appropriate to implement. However, it elucidates the potential of using a machine learning-enabled model to predict the effect on FBG when adjusting basal insulin to overcome some of the clinical inertia challenges.
Conclusion
It was feasible to develop a machine learning-enabled linear model using self-reported FBG, self-reported insulin doses, and blood samples taken at screening to predict the five-week change in FBG following a change in basal insulin dose in people with type 2 diabetes. Such a model may have the potential to facilitate optimized titration potentially reducing non-adherence and treatment fatigue leading to better glycemic control. However, prior to implementation in the real world, the model must undergo further refinement and rigorous testing. This is imperative to ensure that the model can effectively be used to manage glycemic control in people with type 2 diabetes accounting for diverse factors such as the distinct action profiles of basal insulin, concomitant medication, stress levels, and so on.
Footnotes
Acknowledgements
The authors thank Novo Nordisk A/S for providing access to the data used to develop the machine learning model.
Abbreviations
FBG, fasting blood glucose; RAE, relative absolute error; r, Pearson correlation coefficient; R2, coefficient of determination.
Declaration of Conflicting Interests
The author(s) declared the following potential conflicts of interest with respect to the research, authorship, and/or publication of this article: Author P.V. is the head of research at the Steno Diabetes Center North Denmark, funded by the Novo Nordisk Foundation. Author M.H.J holds Novo Nordisk shares.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
