Click the blue WeChat name below the title to quickly follow
Abstract
Objective This study compares the prediction effects of unidimensional and multidimensional input models of Long Short-Term Memory (LSTM) neural networks and Back Propagation (BP) neural networks in the field of dynamic blood sugar.Method This study collected blood sugar values from 18 type 2 diabetes patients at Tianjin Medical University Zhu Xianyi Memorial Hospital from June 2021 to January 2022, along with exercise step counts and dietary caloric intake data from one patient. Two prediction models based on deep learning LSTM neural networks were established: a unidimensional input model using only blood sugar data and a multidimensional input model using blood sugar, step counts, and caloric intake data. The time gradients for predicting future blood sugar were set to 6, 12, and 24 hours, and the Root Mean Square Error (RMSE) between predicted and actual values was calculated to assess the differences between models. A unidimensional prediction model based on BP neural networks was also established for comparison with the LSTM neural network results.Results For predictions at 6, 12, and 24 hours, the RMSE of the unidimensional prediction model based on LSTM neural networks was 0.47, 0.55, and 0.61 respectively; the RMSE of the multidimensional prediction model was 0.31, 0.50, and 0.56 respectively; and the RMSE of the unidimensional prediction model based on BP neural networks was 0.38, 0.59, and 0.63 respectively. Both the unidimensional and multidimensional prediction models based on LSTM neural networks demonstrated high accuracy, with accuracy decreasing as the prediction time gradient increased. Comparison of the same patient confirmed that the multidimensional prediction model had higher accuracy; additionally, the accuracy of LSTM neural network results was higher than that of BP neural network results.Conclusion LSTM neural networks can serve as an effective means in the field of dynamic blood sugar prediction.
Si Jiarui1 Yang Yifei1 Diliyaer Abudukeremu2 Li Jing3
1 Tianjin Medical University, School of Basic Medicine, Tianjin 300070;
2Tianjin Medical University, Second Clinical Medical College, Tianjin 300222;
3Tianjin Medical University Zhu Xianyi Memorial Hospital, Tianjin 300070
Corresponding author: Li Jing, Email: 2003⁃[email protected]
Diabetes is a common chronic disease primarily caused by insufficient insulin secretion or insulin utilization disorders, with typical clinical manifestations including polyuria, polydipsia, polyphagia, weight loss, and abnormal glucose tolerance. Diabetes is divided into type 1 and type 2, with type 2 being more common. The etiology of type 2 diabetes is complex, resulting from various factors such as genetic, environmental, age, racial, and personal lifestyle factors leading to insufficient insulin secretion or insulin resistance. Blood sugar indicators are crucial for controlling the condition of diabetes. Patients with diabetes experience insulin secretion or utilization disorders, and prolonged high blood sugar states can easily lead to disturbances in carbohydrate, protein, and fat metabolism[1]. If blood sugar is not controlled in a timely manner, it can lead to severe complications affecting multiple organs such as the heart, kidneys, and eyes[2], posing a serious threat to the health of patients. To avoid the risks of hypoglycemia, hyperglycemia, and subsequent complications, type 2 diabetes patients need to implement strict self-management (such as diet, exercise, sleep, etc.) to control blood sugar levels. Studies have shown that blood sugar fluctuations in diabetes patients are closely related to their diet and exercise.
In recent years, deep learning technologies have played an increasingly important role in the field of diabetes blood sugar prediction. Recurrent Neural Networks (RNNs) are a type of neural network that takes sequential data as input, recursively processes it in the direction of sequence evolution, with all nodes connected in a chain[3]. Long Short-Term Memory (LSTM) neural networks are a specialized type of RNN that perform better when handling medical data with time series characteristics. However, current research on using LSTM neural networks for blood sugar prediction in diabetes patients remains at a relatively basic stage. Peng Xiuli et al.[4] compared the low blood sugar warning capabilities of LSTM networks with Gated Recurrent Units (GRUs) for type 1 and type 2 diabetes patients, but the warning time scale was too short. Martínez-Delgado et al.[5] used RNN models based on carbohydrate and insulin absorption curves to predict impending blood sugar levels in type 1 diabetes patients but did not consider factors such as exercise and had a small sample size. Rabby et al.[6] proposed a new method for predicting blood sugar levels using a stacked LSTM-based deep recurrent neural network model that accounts for sensor failures, corrected using Kalman smoothing techniques, but there remained significant differences between predicted and actual values.
This study utilizes LSTM neural networks in deep learning, combined with patients’ multidimensional lifestyle data, to predict blood sugar for the next 6, 12, and 24 hours, allowing for early intervention before adverse blood sugar events occur, thereby effectively helping patients maintain blood sugar levels and prevent various complications of diabetes.
Materials and Methods
1. Experimental Data Collection
From June 2021 to January 2022, 18 type 2 diabetes patients who met the following criteria were selected at Tianjin Medical University Zhu Xianyi Memorial Hospital: aged 40-55 years, with stable prior blood sugar, good self-care abilities, no severe complications, and no need for medication. A total of 18 patients were included, and they participated in the experiment after informed consent. One patient collected continuous exercise data for 14 days using a fitness tracker and calculated caloric intake for each meal based on photos of daily meals using the Mint Health APP (Shanghai Mint Health Technology Co., Ltd., version 11.6.3). Continuous blood sugar data were collected using the Abbott Freestyle Libre glucose monitoring system (model: ART33503-001 Rev.D 08/16). Due to the need for a 1-day adaptation period for patients, the data used for model establishment excluded the first day. Among them, 17 patients’ data consisted solely of blood sugar values monitored every 15 minutes, resulting in 96 data points per day. The data from one patient was more complete, including both blood sugar values and exercise and dietary intake data. This study was approved by the Ethics Committee of Tianjin Medical University, with research number TmuhMEC2021006.
2. Statistical Methods
Root Mean Square Error (RMSE) is the square root of the squared deviation between predicted and actual values divided by the number of observations, measuring the deviation between predicted and actual values, and is sensitive to outliers in the data.
Compared to the standard deviation (SD), which measures the dispersion of a dataset, RMSE measures the deviation between predicted and actual values; their research subjects and purposes differ, but the calculation processes are similar.
In this study, RMSE was used to compare the predictive effects of LSTM neural network models and BP neural network models, and to compare the accuracy of multidimensional and unidimensional inputs in the LSTM neural network prediction model.
3. Model Establishment
(1) LSTM Neural Network Unidimensional Input Prediction Model
(1) Since this model only used blood sugar data, both the input and output data dimensions were set to 1. (2) The LSTM layer was set to have 96 hidden units. This study compared results with 48, 96, 192, and 288 hidden units and found that the prediction results were similar, but fewer hidden units required less time. Since 96 corresponds to the amount of blood sugar data for one day, it was selected as the final value. (3) The solver was set to Adam, and training was conducted for 100 epochs. The Adam solver combines the advantages of the AdaGrad and RMSProp optimization algorithms, adjusting the learning rate based on the average of recent weight gradients while also considering accumulated squared gradients, improving performance on sparse gradient problems. Setting the training epochs to 100 also allowed for the selection of the best results through different training epochs. (4) To prevent gradient explosion, the gradient threshold was set to 1. The initial learning rate was set to 0.005, and after 50 epochs, the learning rate was reduced by multiplying by a factor of 0.2 to ensure model convergence. (5) The model prediction calculations were performed using a Graphics Processing Unit (GPU) since prediction calculations on large datasets, long sequences, or large networks are typically faster on GPUs than on Central Processing Units (CPUs). The GPU configuration for this experiment was NVIDIA GeForce GTX 1050.
(2) LSTM Neural Network Multidimensional Input Prediction Model
(1) Since blood sugar, step counts, and caloric intake were used as inputs, with blood sugar as the output, the input data dimension was set to 3 and the output data dimension to 1. (2) The hidden neurons in the LSTM layer were set to 96. (3) The solver was set to Adam, and training was conducted for 100 epochs. (4) The gradient threshold was set to 1, the initial learning rate to 0.005, and after 50 epochs, the learning rate was reduced by multiplying by a factor of 0.2. (5) The model prediction environment was selected as GPU.
(3) BP Neural Network Unidimensional Input Prediction Model
(1) The number of hidden neurons was set to 5, determined by comparing gradients of 100, 50, 25, 10, and 5. When the number of hidden neurons was too large, overfitting occurred, leading to low prediction accuracy, so these cases were discarded. (2) The maximum training epochs were also set to 100. (3) The initial learning rate was set to 0.005.
4. Research Methods
(1) Download the FreeStyle Libre software (Abbott Diabetes Care, UK, version 1.0) to access blood sugar data collected from type 2 diabetes patients by the Abbott Freestyle Libre glucose monitoring system, totaling 18 samples. (2) Export the per-minute exercise data collected by the fitness tracker. (3) Use the Mint Health APP to calculate the calories obtained from food for each meal. (4) Divide the data into two groups: the group of 17 patients with only blood sugar data, establishing a unidimensional prediction model with blood sugar data as input for the LSTM neural network. Due to different wearing days, the amount of data collected varied among different patients. For each patient, the data from the last day before the last day was used as the training set to learn the blood sugar change patterns and establish the LSTM prediction model; the last day’s data served as the test set for dynamic blood sugar prediction over different time gradients (6, 12, 24 hours). The training and test sets must first undergo standardization to achieve better fitting and prevent training divergence. This study employed Z-Score standardization, which is suitable for data with unknown maximum and minimum values and can convert different data to the same scale. (5) Compare the predicted values with the actual blood sugar values of the patients, using RMSE to evaluate the model. (6) For the other patient with more complete information, establish a three-dimensional input LSTM neural network prediction model using blood sugar, exercise, and diet data. Similarly, use the last day’s data as the training set and the last day’s data as the test set for dynamic blood sugar prediction over different time gradients (6, 12, 24 hours) and evaluate the model using RMSE. (7) Based on the BP neural network, establish a unidimensional prediction model for blood sugar and evaluate the model using RMSE. (8) Compare the predictive effects of LSTM neural network prediction models and BP neural network prediction models, and compare the accuracy of multidimensional and unidimensional inputs in the LSTM neural network prediction model.
Results
1. LSTM Neural Network Unidimensional Input Prediction Model
By effectively screening the blood sugar data of 17 patients in the unidimensional input prediction model group, removing some patient data that did not match reality or had local omissions, the actual data selected was from 12 patients. For each patient, the data from the last day before the last day was used as the training set, and the last day’s data as the test set. Taking one patient as an example, the comparison of the predicted values and actual values for the next 24 hours using the LSTM neural network can be seen in Figure 1A and Figure 1B, with local comparisons shown in Figure 1C.
Figure 1 Comparison of predicted values and actual values from the Long Short-Term Memory neural network. In Figure 1A, the red portion represents the predicted values, Figure 1B shows the actual values, and Figure 1C is a local magnification of Figure 1A
Overall, there is still some discrepancy between the predicted values and actual values, but the trend of change generally matches. The RMSE of this model was calculated to be 0.48, indicating that the prediction accuracy of the LSTM neural network is indeed high.
For each patient, predictions were made for blood sugar at future time gradients of 6, 12, and 24 hours, and the RMSE for each model was statistically analyzed and tabulated, concluding that the prediction errors for most patients increased with the prediction time ( Table 1).
2. LSTM Neural Network Multidimensional Input Prediction Model
One patient with comprehensive data was selected, and both multidimensional and unidimensional prediction models were used for comparison, as seen in Figures 2 and 3.
Figure 2 Comparison of predicted values and actual values for the next 24 hours using the multidimensional input prediction model
Figure 3 Comparison of predicted values and actual values for the next 24 hours using the unidimensional input prediction model
From the comparison between Figures 2 and 3, it can be seen that both prediction models have high accuracy, but the multidimensional input model is more accurate. From the data, the RMSE of the multidimensional input model is 0.56, while the RMSE of the unidimensional input model is 0.61, which further supports this viewpoint. Additionally, relying on exercise and dietary data, the multidimensional prediction model can predict blood sugar changes more accurately during certain moments of fluctuation. For example, in the first 8 hours (the first 32 points on the x-axis), although there is a certain time deviation in the multidimensional prediction model, the trend and magnitude of blood sugar changes are predicted very accurately. Meanwhile, the unidimensional prediction model not only shows a significant difference between the predicted blood sugar values and actual values during this period but also fails to predict the trend of blood sugar changes as effectively as the multidimensional prediction model.
Table 2 shows the RMSE comparison of the two models for the next 6, 12, and 24 hours. It can be seen that as the prediction time increases, the accuracy of the models decreases, which is consistent with the patterns summarized in the unidimensional prediction model. Moreover, based on the three time gradients set, the multidimensional prediction model is more accurate than the unidimensional prediction model, indicating that the inclusion of exercise and dietary data positively impacts the model’s predictions.
3. BP Neural Network Unidimensional Input Prediction Model
BP neural networks are multilayer feedforward neural networks trained using the error backpropagation algorithm, based on the principle of gradient descent, utilizing gradient search techniques to minimize the mean squared error between the actual output values and expected output values.
Using one patient from the 12 patients as an example, the comparison of predicted values and actual values for the next 24 hours using the BP neural network can be seen in Figure 4A and Figure 4B, with local comparisons shown in Figure 4C.
Figure 4 Comparison of predicted values and actual values from the Back Propagation neural network. In Figure 4A, the red portion represents the predicted values, Figure 4B shows the actual values, and Figure 4C is a local magnification of Figure 4A
From Figure 4, it can be seen that the BP neural network’s prediction results are generally correct in trend, but the prediction accuracy is poor. Additionally, Table 3 shows the comparison of RMSE values from the unidimensional prediction models of both LSTM and BP neural networks.
Table 3 clearly shows that for the same prediction time, the RMSE of the LSTM neural network is much lower than that of the BP neural network, indicating that the accuracy of the LSTM neural network is higher and more suitable for blood sugar prediction.
Discussion
Recent studies have shown an increasing application of LSTM neural networks in diabetes and its complications. Faruqui et al.[7] developed a transfer learning strategy based on weighted sampling from all patients to personalize dynamic predictions of blood sugar levels in type 2 diabetes patients using LSTM neural networks, achieving high accuracy. Zhu Qian et al.[8] compared the predictive effects of Generalized Additive Models (GAM) and LSTM-RNN on hospitalization frequency in patients with diabetes and respiratory diseases, concluding that LSTM-RNN had smaller prediction errors and better fitting, suggesting it can be used as a predictive tool for the precise allocation of medical resources in polluted weather. Liu et al.[9] proposed a data-driven diabetes classification model using graph convolutional networks to learn daytime influencing features and LSTM networks to characterize daytime blood sugar changes, achieving accurate classification for both type 1 and type 2 diabetes. These research results demonstrate the advantageous data processing performance of LSTM neural networks.
This study utilized continuous blood sugar monitoring technology for real-time monitoring of blood sugar levels in diabetes patients. The Abbott Freestyle Libre glucose monitoring system primarily monitors glucose concentration in interstitial fluid via a probe embedded in subcutaneous tissue, indirectly obtaining blood sugar concentration[10]. Although glucose in interstitial fluid lags behind real-time blood sugar by a few minutes, it has gained recognition[11]. Clinical studies by Thomas et al.[12] show that this system can effectively improve patients’ blood sugar levels more quickly and assist patients in insulin usage. Additionally, fitness trackers and related apps were used to obtain exercise and dietary caloric data. After obtaining relevant data, the study used LSTM neural networks to predict blood sugar levels in diabetes patients, analyzing past blood sugar data to accurately predict dynamic blood sugar changes over a period of time. The study compared the unidimensional and multidimensional prediction models of the LSTM neural network and the unidimensional prediction models of the BP neural network, calculating the RMSE of predicted and actual values to effectively evaluate the differences between the three prediction models, confirming the effectiveness and accuracy of the LSTM neural network model in handling time series data like dynamic blood sugar prediction, thus allowing patients to understand the general trend of blood sugar data over the next period and take corresponding measures to control blood sugar. However, this study still has certain limitations: some patient data had omissions and missing values, leading to reduced validity and accuracy of some experimental data, rendering them unusable; the overall sample size of experimental data was small, affecting the persuasiveness of the results, necessitating further experiments to supplement.
In summary, both prediction models based on LSTM neural networks exhibited high accuracy, and the shorter the predicted future time, the higher the accuracy. The highest accuracy in the unidimensional prediction model was for predicting the future 6 hours of blood sugar changes for patient 12, with an RMSE of only 0.09, almost no difference from the actual values. The multidimensional input prediction model showed higher accuracy than the unidimensional input prediction model, with an average RMSE lower by 0.09 at the same prediction time, indicating that inputting exercise and dietary data can effectively improve the prediction performance of the model. Simultaneously, the RMSE of the unidimensional prediction model based on BP neural networks was higher than that of the LSTM neural network for future predictions at different times, indicating lower accuracy than the LSTM neural network. The above results demonstrate the advantages of LSTM neural networks in handling time series data like blood sugar, serving as an effective means in the field of dynamic blood sugar prediction, thereby providing a basis for patients to take early intervention measures against potential adverse blood sugar events.
(References can be found on the journal’s website)
Journal Introduction
The Journal of Digital Medicine and Health (CN 10-1909/R, ISSN 2097-3349) is an interdisciplinary academic journal sponsored by the Chinese Association for Science and Technology and the Chinese Medical Association. It has been included in the “Full-text Database of Chinese Medical Journals”.
The purpose of the journal: to focus on the latest development directions in the field of digital medicine and health at home and abroad, publish new theories, technologies, and methods in the field of digital medicine and health, and build a platform for academic and technical exchange and cooperation to support the “Healthy China” strategy.
Reporting scope: frontier progress in the field of digital medicine and health at home and abroad; applications of digital and information technologies in public health, disease prevention, health management, precision medicine, decision support, drug development, clinical research, industry governance, hospital management, medical education, medical insurance, data management, and security; new theories, technologies, and viewpoints in the interdisciplinary fields related to medicine and health and modern informatics; national policies and regulations, industry standards and consensus, evidence-based guidelines, ethical requirements, and industrial information in the field of digital medicine and health.
Main columns: Reviews, Expert Discussions, Standards and Norms, Original Articles, Research Methods and Reports, Reviews, Industry Research, Future Medicine, Technology Introductions and Evaluations, Ethics and Regulation, Lectures, Literature Reviews, etc.
Editorial office address: Room 405, No. 69 Dongheyuan Street, Xicheng District, Beijing, Postal Code: 100052.
Contact number: 010-51322158, Email: [email protected].
More Reading:
Submission Guidelines and Instructions for the Journal of Digital Medicine and Health