CNN-LSTM physiological index prediction method and prediction system based on dynamic sampling and attention mechanism
Through the CNN-LSTM model that dynamically adjusts the sampling frequency and time interval combined with attention mechanism, the problem of untimely prediction and low accuracy in the detection of physiological indicators of chronic diseases is solved, and efficient and accurate prediction of changes in physiological indicators is achieved, and timely adjustments are supported for patients and doctors to control them.
Patent Information
- Application Number
- CN202311788726.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2025-07-04
AI Technical Summary
The existing methods for detecting physiological indexes of chronic diseases have problems such as untimely prediction and low accuracy, especially when physiological indexes fluctuate, and traditional models are unstable in training when there are large individual differences and large data volumes.
The CNN-LSTM physiological index prediction method based on dynamic sampling and attention mechanism is adopted. By dynamically adjusting the sampling frequency and time interval, combined with Kalman filtering and attention mechanism, the CNN-LSTM model is improved to improve the learning of the changing state of physiological indexes and enhance the prediction accuracy.
It achieves more accurate prediction of changes in physiological indicators, helps patients to make timely adjustments, reduces false alarms and missed reports, and improves the accuracy and reliability of physiological indicator monitoring.
Smart Images

Figure CN120241048A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of physiological index monitoring, and in particular relates to a CNN-LSTM physiological index prediction method and prediction system based on dynamic sampling and attention mechanism. Background Art
[0002] With the development of the economy and the improvement of living standards, more and more people like high-sugar, high-fat and heavy-taste diets, and lack exercise and have irregular work and rest, resulting in an increased risk of suffering from chronic diseases such as hyperglycemia, hypertension, hyperlipidemia, hyperuricemia, hyperketonemia, and hypothyroidism, and the age tends to be younger. In 2012, it was statistically found that the prevalence of hypertension among adults aged 18 and above in the country was 25.5%, and the prevalence of diabetes was 9.7%.
[0003] The traditional detection method for chronic disease physiological indicators is to measure by frequently taking blood or to measure once as needed using an instrument. This method has a time delay in evaluating the fluctuation of the patient's physiological indicators and formulating medical plans, is inconvenient for the patient to manage physiological indicators, and cannot maintain the stability of the patient's physiological indicators in a timely manner. Therefore, the method of long-term and continuous monitoring can provide the formulation of medical plans and the stability of physiological indicators for patients better and faster.
[0004] For blood glucose, the traditional method is self-monitoring of blood glucose (SMBG), that is, the combination of a blood glucose meter and test strips to detect glucose in the blood; the method of long-term and continuous monitoring is semi-implantation, full implantation or non-invasive wearing method, using a sensor to receive and output signals to evaluate the fluctuation of the patient's physiological indicators and guide the formulation of a hypoglycemic plan. At present, there are continuous physiological index monitors for various physiological indicators, and they have been gradually promoted and applied clinically.
[0005] During the process of continuous monitoring of physiological indicators, although patients will be reminded to pay attention to adjusting physiological indicators such as blood glucose, blood pressure, and blood ketone to prevent physical discomfort, the prompts based on the current test results cannot meet the needs of patients to adjust physiological indicators in a timely manner. For example, when blood glucose or blood pressure drops, the patient will feel dizzy and have no time to take actions to adjust their physical health. Therefore, during the process of continuous monitoring of physiological indicators, it is necessary to predict the changes in physiological indicators in the future faster and more accurately and remind the patient to take corresponding measures.
[0006] Prediction models are mainly divided into two categories. One is prediction based on physiological models, and the other is data-driven prediction. Prediction based on physiological models is relatively complex, involving a large number of parameters in the process. Physiological indicators are a real-time regulation process in the human body, with large individual differences, high feature dimensions, and many interfering factors, resulting in difficulties in parameter identification and model establishment during the modeling process, complex prediction, and low prediction accuracy. At the same time, with the development of sensor technology, through the collection of physiological indicator data, based on historical physiological indicator values, operating on real-time boundaries, the prediction accuracy and universality are relatively good. Therefore, a data-driven prediction model is adopted. However, for longer input data, the more abundant and larger the amount of information it contains, the single data-driven prediction model will show unstable and inaccurate phenomena during training.
[0007] The physiological indicator data collected by continuous monitoring instruments is non-linear and non-stationary, which will have a certain impact on the prediction accuracy. Therefore, it is necessary to construct a better prediction model that can provide more accurate prediction information for chronic disease patients, so as to make timely adjustments to help the physiological indicators be in a good control range. Summary of the Invention
[0008] In order to overcome the deficiencies of the prior art, the present invention provides a CNN-LSTM physiological indicator prediction method and prediction system based on dynamic sampling and attention mechanism.
[0009] The technical solution adopted by the present invention to solve its technical problems is: A CNN-LSTM physiological indicator prediction method based on dynamic sampling and attention mechanism, comprising the following steps:
[0010] Data collection: In the initial state, collect the original physiological indicator data at a sampling frequency of s and a sampling time interval of t. When it is determined that the physiological indicator reaches the threshold, update the sampling frequency to s' and the sampling time interval to t' to collect the original physiological indicator data;
[0011] Original processing: Perform data insertion processing on the original physiological indicator data to form original physiological indicator data with a fixed time interval;
[0012] Preprocessing: Smooth the original physiological indicator data to obtain the filtered historical physiological indicator data;
[0013] Build a CNN-LSTM model based on the attention mechanism;
[0014] Model training: The historical physiological indicator data is segmented into input and output data of the CNN-LSTM model by the sliding window method. Use N historical physiological indicator data with a sampling time interval of t' as the input, and M future physiological indicator values with a time interval of t as the output;
[0015] Predict the physiological index value. Input the data to be tested into the trained CNN-LSTM model based on the attention mechanism to obtain the predicted physiological index value.
[0016] Further, denote the current moment as t, and respectively take the physiological index values v t-1 , v t , v t+1 at at least three time points. Take the difference between every two physiological index values to obtain x t and x t+1 ; When the physiological index changes from the initial state to the rising or falling state or from the stable state to the rising or falling state, start to adjust the sampling frequency and sampling time interval to collect the original physiological index data;
[0017] That is, when it is monitored that the product of x t and x t+1 is greater than or equal to Y 2 t 2 , it is determined that the physiological index reaches the first threshold set for the rising or falling state, and adjust the sampling frequency to s' greater than s and the sampling time interval to t' less than t to collect the original physiological index data, where Y is the maximum value of the reasonable change in mmol / L per minute (min) of the physiological index;
[0018] Or when it is monitored that the product of x t and x t+1 is less than 0 and the absolute value of x t+1 is less than 0.5Yt, it is determined that the physiological index reaches the second threshold set for the rising or falling state, and adjust the sampling frequency to s' greater than s and the sampling time interval to t' less than t to collect the original physiological index data;
[0019] When the physiological index tends to be stable from the rising or falling state, adjust the sampling frequency and sampling time interval again to collect the original physiological index data;
[0020] Further, that is, when it is monitored that the product of x t and x t+1 is less than 0 and x t+1 is greater than or equal to the absolute value of 0.5Yt, it is determined that the physiological index is in the stable state, that is, it reaches the third threshold, and adjust the sampling frequency to s' less than or equal to s and the sampling time interval to t' greater than or equal to t to collect the original physiological index data;
[0021] Or when it is monitored that the product of x t and x t+1 is greater than or equal to 0 and less than Y 2 t 2When it is determined that the physiological index is in a stable state, i.e., reaching the fourth threshold, the sampling frequency is adjusted to s' which is less than or equal to s, and the sampling time interval is adjusted to t' which is greater than or equal to t to collect the original physiological index data.
[0022] Further, when the physiological index is blood glucose, Y is 0.06 - 0.1 mmol / L, preferably Y is 0.1 mmol / L. When the physiological index changes to an increasing or decreasing state, i.e., when it is determined that the physiological index reaches the first or second threshold, the sampling frequency s' is 2s, and the sampling time interval t' is t / 2; when the physiological index tends to a stable state from the increasing or decreasing state, i.e., when it is determined that the physiological index reaches the third or fourth threshold, the sampling frequency s' is s / 2, and the sampling time interval t' is 2t; or when it is determined that the physiological index reaches the third or fourth threshold, the sampling frequency s' is s, and the sampling time interval t' is t.
[0023] Further, in the preprocessing step, the original physiological index data obtained after the original data processing is smoothed by Kalman filtering to obtain the filtered historical physiological index data;
[0024] The Kalman filtering process includes the following steps.
[0025] Prediction step, estimating the state at the next moment through the state at the previous moment. The specific formula is,
[0026]
[0027] P t - = FP t-1 F + Q(1.10)
[0028] Correction step, estimating the optimal state for the state at the current moment. The specific formula is,
[0029] K t = P t - H T (HP t - H T + R) -1 (1.11)
[0030]
[0031] P t = (I + K t H)P t (1.13)
[0032] Among them, x represents the state matrix of the system, t represents a certain moment, - represents the estimated value, F is the state transition matrix, B is the control matrix, u t-1represents the control quantity of the system at the previous moment, K is the Kalman gain, P is the covariance, I is the identity matrix, Q is the noise, H is the measurement matrix, Z is the observation matrix, R is the noise matrix, and x t is the posterior estimate value, that is, the output value.
[0033] Furthermore, in the original processing steps, outlier processing is also performed on the physiological index data. After removing the outliers, the missing intervals are classified according to the amount of data missing and filled separately.
[0034] Furthermore, the steps for building the model are as follows
[0035] Input the historical physiological index data into the CNN model. Through the convolutional layer and the pooling layer, feature extraction and dimensionality reduction of the data are achieved;
[0036] The data processed by the CNN model is used as the input of the LSTM model. The LSTM model passes the input feature data through the forget gate, input gate, and output gate, and iteratively adjusts the parameters of the input data, enabling it to learn the temporal relationship between the data from the feature data extracted by the CNN model and model the input data of the time series;
[0037] The data trained by the CNN-LSTM model outputs the prediction value through the fully connected layer.
[0038] Furthermore, the model parameters consist of two convolutional layers, two pooling layers, one LSTM layer, and one fully connected layer Dense; the number of convolutional kernels in the two convolutional layers is 64 and 128 respectively, the size of the convolutional kernel is 2, 0 padding is used, and the activation function uses Relu; the pooling layer uses max pooling with a size of 2; the number of neurons in the LSTM layer is 128; 20% dropout is added before Dense to make 20% of the neurons inactive, and finally the Dense layer outputs, with the output dimension being the same as the number of prediction labels.
[0039] Furthermore, an attention mechanism is added to the model. The formula for obtaining the dimension weights is and the sum of the weights of each dimension is 1.
[0040] Furthermore, an alarm step is also included, which is at least set with a first limit range and a second normal range. The first limit range is the range exceeding the normal physiological index. When the physiological index is blood glucose, the normal physiological index range is 3 - 27.8 mmol / L; the second normal range at least includes the mode ranges for children and adolescents, adults, and the elderly.
[0041] The present invention also discloses a prediction system for a CNN-LSTM physiological index prediction method based on dynamic sampling and attention mechanism.
[0042] For implementing the above physiological index prediction method, including:
[0043] A data acquisition unit, in the initial state, acquires the original physiological index data at a sampling frequency s and a sampling time interval t. When it is determined that the physiological index reaches the threshold, the sampling frequency is updated to s' and the sampling time interval is updated to t' to acquire the original physiological index data;
[0044] An original processing unit, which performs inserted data processing on the original physiological index data to form original physiological index data with a fixed time interval;
[0045] A preprocessing unit, which performs smoothing processing on the original physiological index data to obtain the filtered historical physiological index data;
[0046] A CNN-LSTM model unit based on the attention mechanism;
[0047] A model training unit, which uses the sliding window method to split the historical physiological index data into the input and output data of the CNN-LSTM model. The N historical physiological index data with a sampling time interval of t' are used as the input, and the M future physiological index values with a time interval of t are used as the output;
[0048] A prediction unit, which inputs the data to be tested into the trained CNN-LSTM model based on the attention mechanism to obtain the predicted physiological index value.
[0049] In the process of physiological index prediction based on the physiological model, a large number of parameters are involved, with significant individual differences and high feature dimensions, making the prediction relatively complex. Using the data-driven method, instability will occur during training for longer input data, and the prediction results are not accurate enough. The key focus stage of physiological index prediction lies in the increase and decrease of physiological indexes. However, the data in this stage often cannot be collected more, resulting in insufficient learning of this stage by the model, thus causing accuracy problems. To address this issue, the present invention proposes to collect data using a dynamically adjusted sampling method, enabling the model to learn more fully about the rising and falling states of physiological indexes and making the prediction more accurate; at the same time, the accuracy of the prediction model not only helps patients with medication significantly, but also indirectly helps doctors effectively control the physiological index levels of patients. Furthermore, a CNN-LSTM physiological index prediction method based on the attention mechanism is proposed to improve the accuracy of physiological index prediction, facilitating patients to more accurately understand their own physiological index conditions and make timely adjustments through higher-precision prediction.
[0050] The present invention provides a CNN-LSTM model, which utilizes the feature extraction ability of CNN to extract historical physiological index data into high-dimensional features of short sequences. Combining the dependence of LSTM on data and time, LSTM comprehensively processes the high-dimensional features extracted by CNN to achieve prediction and obtain physiological index prediction values with temporal correlation. Moreover, an attention mechanism module is added to the CNN-LSTM model. This module calculates the weight matrix for each feature dimension, and the importance of the input features is reflected by the weight values, enabling the model to focus on the most effective information with limited resources, removing interference from redundant information, and helping to reduce problems such as the loss of important features caused by ignoring the importance of features and the mining of regular patterns in long sequences of physiological index data, thereby enhancing the prediction ability for temporal physiological index data.
[0051] The beneficial effects of the present invention are as follows: 1) By setting thresholds to judge the rising, falling, and stable states of physiological indexes, the method dynamically adjusts the sampling frequency and sampling time interval to collect data on the changing states of physiological indexes, and forms original physiological index data with a fixed time interval through data insertion processing of the originally collected physiological index data at low frequency, ensuring that the model learns the rising and falling states of physiological indexes sufficiently, making data prediction more accurate, helping patients take medicine accurately, and indirectly helping doctors effectively control the physiological index levels of patients; 2) The CNN-LSTM model based on the attention mechanism can focus on the most effective information with limited resources, enhance the prediction ability for temporal physiological index data, ensure the accuracy of prediction, and facilitate patients to more accurately understand their own physiological index conditions and make timely adjustments; 3) In the original processing steps, outliers are removed from the physiological index data, and filling is performed separately according to the level of data missing amount, improving the quality and effectiveness of the original data, and making the model training more excellent; 4) An alarm step is set, which can timely give early warnings for high physiological indexes, low physiological indexes, or abnormal physiological index moments, facilitating subsequent adjustment or treatment of physiological indexes by users; 5) A dual range is set for the alarm, and strict requirements are imposed on the confirmation conditions for the predicted data to meet the alarm requirements, improving the accuracy of the alarm to reduce false alarms and missed alarms, and preventing incorrect adjustment of physiological index values due to misjudgment, which may cause unnecessary impacts on the patient's body. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flow schematic diagram of the present invention.
[0053] Figure 2 It is a schematic diagram of a sliding window in the present invention.
[0054] Figure 3 It is a schematic diagram of the CNN-LSTM model structure in the present invention.
[0055] Figure 4Schematic diagram of the structure after adding the attention mechanism module to the LSTM layer in the present invention.
[0056] Figure 5 Schematic diagram of the structure of the LSTM model in the present invention.
[0057] Figure 6 Curve graph of the prediction results of three models with regular sampling at a prediction time of 5 minutes.
[0058] Figure 7 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 5 minutes.
[0059] Figure 8 Curve graph of the prediction results of three models with regular sampling at a prediction time of 10 minutes.
[0060] Figure 9 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 10 minutes.
[0061] Figure 10 Curve graph of the prediction results of three models with regular sampling at a prediction time of 15 minutes.
[0062] Figure 11 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 15 minutes.
[0063] Figure 12 Curve graph of the prediction results of three models with regular sampling at a prediction time of 20 minutes.
[0064] Figure 13 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 20 minutes.
[0065] Figure 14 Curve graph of the prediction results of three models with regular sampling at a prediction time of 25 minutes.
[0066] Figure 15 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 25 minutes.
[0067] Figure 16 Curve graph of the prediction results of three models with regular sampling at a prediction time of 30 minutes.
[0068] Figure 17 Partially enlarged curve graph of the prediction results of three models with regular sampling at a prediction time of 30 minutes.
[0069] Figure 18 Curve graph of the true value and prediction results of the regular sampling CNN-LSTM model at a prediction time of 5 - 30 minutes.
[0070] Figure 19 The curve graph of the prediction results of the CNN-LSTM model with and without the attention mechanism module for regular sampling at the prediction time of 30 minutes.
[0071] Figure 20 The partially enlarged curve graph of the prediction results of the CNN-LSTM model with and without the attention mechanism module for regular sampling at the prediction time of 30 minutes.
[0072] Figure 21 The line graph of the comparison of the mean square errors of different models at different prediction times under regular sampling.
[0073] Figure 22 The line graph of the comparison of the mean square errors of different models at different prediction times under dynamic sampling.
[0074] Figure 23 The curve graph of the comparison of the prediction results of the CNN-LSTM models under regular sampling and dynamic sampling at the prediction time of 30 minutes.
[0075] Figure 24 The partially enlarged curve graph of the comparison of the prediction results of the CNN-LSTM models under regular sampling and dynamic sampling at the prediction time of 30 minutes.
[0076] Figure 25 The curve graph of the comparison of the prediction results of the CNN-LSTM-attention models under regular sampling and dynamic sampling at the prediction time of 30 minutes.
[0077] Figure 26 The partially enlarged curve graph of the comparison of the prediction results of the CNN-LSTM-attention models under regular sampling and dynamic sampling at the prediction time of 30 minutes. Detailed implementation manners
[0078] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0079] As Figure 1 shown, a CNN-LSTM physiological index prediction method based on dynamic sampling and attention mechanism includes the following steps:
[0080] Data acquisition. In the initial state, the original physiological index data is collected at a sampling frequency of s and a sampling time interval of t. When it is determined that the physiological index reaches the threshold, the sampling frequency is updated to s' and the sampling time interval is updated to t' to collect the original physiological index data;
[0081] Specifically, when determining the threshold at which the physiological index reaches the rising or falling state from the initial state or the stable state, the sampling frequency is updated to s' greater than s, and the sampling time interval is updated to t' less than t. When the physiological index reaches the stable state threshold from the rising or falling state, the sampling frequency is updated to s' less than or equal to s, and the sampling time interval is updated to t' greater than or equal to t to collect the original physiological index data. There are two ways to set the above rising or falling state thresholds and two ways to set the stable state thresholds. In this embodiment, when the physiological index is blood glucose, in the initial state, the original blood glucose data is collected at a sampling frequency s of 5 minutes per time and a sampling time interval t of 5 minutes. When the blood glucose changes from the initial state to the rising or falling state, the sampling frequency s' is updated to 2.5 minutes per time and the sampling time interval t' is updated to 2.5 minutes to collect the original blood glucose data. Of course, in other embodiments, the updated sampling frequency s' can be any frequency greater than s, and the updated sampling time interval t' can be any time interval less than t, without specific limitation. When the blood glucose tends to the stable state from the rising or falling state, the sampling frequency s' is updated to 5 minutes per time and the sampling time interval t' is updated to 5 minutes. Of course, in other embodiments, the updated sampling frequency s' can be any frequency less than or equal to s, and the updated sampling time interval t' can be any time interval greater than or equal to t, without specific limitation. When the blood glucose changes from the stable state to the rising or falling state, the sampling frequency s' is updated to 2.5 minutes per time and the sampling time interval t' is updated to 2.5 minutes to collect the original blood glucose data. When the physiological index is blood ketone, in the initial state, the original blood ketone data is collected at a sampling frequency s of 5 minutes per time and a sampling time interval t of 5 minutes. When the blood ketone changes from the initial state to the rising or falling state, the sampling frequency s' is updated to 2.5 minutes per time and the sampling time interval t' is updated to 2.5 minutes to collect the original blood ketone data. When the blood ketone tends to the stable state from the rising or falling state, the sampling frequency s' is updated to 10 minutes per time and the sampling time interval t' is updated to 10 minutes to collect the original blood ketone data. When the blood ketone changes from the stable state to the rising or falling state, the sampling frequency s' is updated to 2.5 minutes per time and the sampling time interval t' is updated to 2.5 minutes to collect the original blood ketone data. When the physiological index is uric acid, in the initial state, the original uric acid data is collected at a sampling frequency s of 60 minutes per time and a sampling time interval t of 60 minutes. When the uric acid changes from the initial state to the rising or falling state, the sampling frequency s' is updated to 30 minutes per time and the sampling time interval t' is updated to 30 minutes to collect the original uric acid data. When the uric acid tends to the stable state from the rising or falling state, the sampling frequency s' is updated to 120 minutes per time and the sampling time interval t' is updated to 120 minutes to collect the original uric acid data. When the uric acid changes from the stable state to the rising or falling state, the sampling frequency s' is updated to 30 minutes per time and the sampling time interval t' is updated to 30 minutes to collect the original uric acid data.
[0082] In the original processing, the data in the original state and the stable state are less compared to the original physiological index data collected in the rising or falling state. That is, the data with a sampling time interval greater than or equal to t will be missing. Therefore, it is necessary to perform data insertion processing on the original physiological index data with a sampling frequency less than or equal to s and a sampling time interval greater than or equal to t to form the original physiological index data with a fixed time interval. Here, a fixed time interval means that t' with a sampling time interval less than t is used as the fixed time interval;
[0083] Preprocessing: Use Kalman filtering to smooth the original physiological index data (ori_G) obtained after the original processing step to obtain the filtered historical physiological index data (filter_G);
[0084] Build a CNN-LSTM model based on the attention mechanism;
[0085] Model training: The historical physiological index data is segmented into the input and output data of the CNN-LSTM model by the sliding window method. N historical physiological index data with a sampling time interval of t' are used as the input, and M future physiological index values with a time interval of t are used as the output; the above t' refers to a sampling time interval less than t, which can be t / 2 or t / 3, and can be adjusted according to the sampling frequency s;
[0086] Predict the physiological index value: Input the data to be tested into the trained CNN-LSTM model based on the attention mechanism to obtain the predicted physiological index value at the prediction time.
[0087] Specifically,
[0088] Data acquisition step: Collect physiological index data through a detection device with an original sampling frequency of s and a sampling time interval of t. The physiological index detection device can be an instant detection device, a non-invasive wearable device, or a continuous monitoring device. The continuous monitoring device includes a semi-implanted continuous monitoring device and a fully implanted continuous monitoring device. Collecting the original physiological index data through a non-invasive wearable device or a continuous monitoring device can alleviate the lack of original physiological index data to a certain extent. And by increasing the sampling frequency in the rising or falling state, reducing the sampling frequency in the stable state, and performing data insertion processing on the original physiological index data collected at a low sampling frequency, the original historical data with a shortened and fixed time interval is formed, and the outliers and missing values in the original historical data are processed to obtain the fully processed original historical data. When the physiological index is blood glucose and blood ketone, here the shortened and fixed time interval means t' is 2.5 min. When the physiological index is uric acid, here the shortened and fixed time interval means t' is 30 min.
[0089] The main purpose of realizing real-time prediction of physiological indicators is to monitor high or low physiological indicators in real time, facilitating patients to take corresponding preventive measures in advance. Therefore, when using a model to learn historical physiological indicator data, the characteristics of the increased or decreased parts of physiological indicators need to be focused on. However, the data collected by physiological indicator detection devices with a fixed sampling time interval have a fixed time interval, and less learning of the increased or decreased data parts of physiological indicators may lead to insufficient model learning, which has a certain impact on the accuracy of the predicted high or low physiological indicator data. Therefore, to address this problem, it is proposed to dynamically adjust the sampling frequency of the physiological indicator detection device, increase the sampling frequency for the increased or decreased state of physiological indicators, shorten the sampling time interval to obtain more data volume for this part, and reduce the sampling frequency for the stable state of physiological indicators, increase the sampling time interval to reduce the data volume obtained for this part.
[0090] Specifically, set the current moment as t, and respectively take the physiological indicator values v t-1 , v t , v t+1 at three time points. Subtract each pair of physiological indicator values from each other to obtain x t and x t+1 :
[0091] When x t or x t+1 is greater than or equal to the physiological indicator value calculated based on the physiological indicator change of Y mmol / L per minute and the sampling time interval t, it indicates that the physiological indicator has an upward trend or a downward trend in this stage; when x t or x t+1 is within the range where the physiological indicator change per minute is less than Y mmol / L and the sampling time interval t, it indicates that the physiological indicator is relatively stable in this stage. When the physiological indicator is blood glucose, Y is 0.06 - 0.1 mmol / L, preferably Y is 0.1 mmol / L. The judgment criteria for upward or downward trends are shown in Formulas 1.1 and 1.2. When the physiological indicator is blood ketone, Y is 0 - 0.008 mmol / L, preferably Y is 0.008 mmol / L;
[0092] When the physiological indicator changes from the initial state to the upward or downward state or from the stable state to the upward or downward state, start to adjust the sampling frequency and sampling time interval to collect the original physiological indicator data. There are two thresholds for judging whether the physiological indicator is in the upward or downward state;
[0093] The first threshold: If the detection device determines that the physiological indicator has two consecutive upward trends or downward trends, then it is judged that the physiological indicator is in the upward state or the downward state, and the sampling frequency is updated to s' greater than s, and the sampling time interval is updated to t' less than t. That is, when the product of x t and x t+1 is greater than or equal to Y2 t 2 When it is t, this is taken as the first threshold set for judging that the physiological index reaches the rising or falling state. After judging that the physiological index is in the rising or falling state, starting from the (t + 1)th moment, the sampling frequency is adjusted to s' which is greater than s, and the sampling time interval is adjusted to t' which is less than t. When the detection index is blood glucose, that is, when the t product of x t+1 and x is greater than or equal to 0.01t 2 this is taken as the first set threshold for judging that the blood glucose reaches the rising or falling state. As shown in Equation 1.3, the sampling frequency s' is adjusted to 2.5 min / time, and the sampling time interval t' is adjusted to 2.5 min;
[0094] Second threshold: When the t product of x t+1 and x is less than 0 and the absolute value of x t+1 is less than 0.5Yt, this is also taken as the judgment that the physiological index is in the rising or falling state, and the sampling frequency is updated to s' which is greater than s, and the sampling time interval is updated to t' which is less than t. When the detection index is blood glucose, that is, when the t product of x t+1 and x is less than 0 and the absolute value of x t+1 is less than 0.05t, it is judged that the physiological index is in the rising or falling state. As shown in Equation 1.4(1), the sampling frequency s' is adjusted to 2.5 min / time and the sampling time interval t' is adjusted to 2.5 min;
[0095] When the physiological index tends to the stable state from the rising or falling state, the sampling frequency and the sampling time interval are adjusted again to collect the original physiological index data. There are two thresholds for judging that the physiological index is in the stable state;
[0096] Third threshold: When the t product of x t+1 and x is less than 0 and the absolute value of x t+1 is greater than or equal to 0.5Yt, it is judged that the physiological index is in the stable state, and the sampling frequency is updated to s' which is less than or equal to s, and the sampling time interval is updated to t' which is greater than or equal to t. The original sampling frequency s and the original sampling time interval t can be continued to be used, or a lower sampling frequency and a longer sampling time interval can be used. When the detection index is blood glucose, that is, when the t product of x t+1 and x is less than 0 and the absolute value of x t+1 is greater than or equal to 0.05t, as shown in Equation 1.4(2), it is judged that the physiological index is in the stable state, and the sampling frequency is adjusted to 5 min / time and the sampling time interval is adjusted to 5 min;
[0097] Fourth threshold: When the t product of x t+1The product is greater than or equal to 0 and less than Y 2 t 2 When it is, it is determined that the physiological index is in a stable state, the sampling frequency is updated to s' which is less than or equal to s, and the sampling time interval is updated to t' which is greater than or equal to t. The original sampling frequency s and the original sampling time interval t can continue to be used, or a reduced sampling frequency and a longer sampling time interval can be used; when the detection index is blood glucose, that is, when x t and x t+1 The product is greater than or equal to 0 and less than 0.01t 2 When it is, as shown in formula 1.4(3), it is determined that the physiological index is in a stable state, the sampling frequency is adjusted to once every 5 minutes, and the sampling time interval is adjusted to 5 minutes.
[0098] x t =v t -v t-1 ≥±0.1t (1.1)
[0099] x t+1 =v t+1 -v t ≥±0.1t (1.2)
[0100] x t+1 ×x t ≥0.01t 2 (1.3)
[0101]
[0102] 0≤x t ·x t+1 <0.01t 2 (3)
[0103] For the original processing steps, the data after dynamic adjustment will have at least 2 time intervals, namely t and t'. Therefore, it is necessary to perform dynamic processing on the physiological index data in the initial state and the stable state. That is, when the time interval of the data segment is less than or equal to t, data insertion is performed on the data segment, and it is adjusted to a time interval greater than t. When the time interval of the data segment is greater than t, no processing is performed. For example, the data segment v1, v2, v3... v t-1 ,v tIf the time interval is t, then the physiological index value v1 at time t = 1 and the physiological index value v2 at time t = 2 are taken. The ratio of the values is adjusted with reference to the ratio of each time interval. Specifically, when the physiological index is blood glucose, it is t in the initial state; when the blood glucose is in the rising or falling state, t’ is t / 2; when the blood glucose is in the stable state, t’ is t. According to formula 1.5, the average value of v1 and v2 is taken, and the newly obtained physiological index value v is inserted between t = 1 and t = 2. By analogy, the interpolation process of the data segment is completed. If a data segment with a time interval of t / 2 is encountered, no processing is performed. Finally, the original physiological index data is processed into the original physiological index data with a time interval of t / 2.
[0104]
[0105] For the outlier processing in the original processing steps, it is for outliers (outliers refer to some data values in the data observation that are much larger or smaller than the overall value of the sample or the mutation of a single data). For data values that are much larger or smaller than the overall value of the sample, they are screened by formula 1.6, that is, when the value is greater than 3 times the original physiological index value or the value is less than 1 / 3 times the original physiological index data, it is defined as an outlier, as shown in formula 1.6.
[0106]
[0107] For outliers with a single data mutation, formula 1.7 is used for judgment. When the physiological index is blood glucose and t is 5 min, it is judged through v t+1 and V t-1 to judge the value of v t When v t is greater than 0.2t times of V t-1 and v t+1 is greater than the absolute value of 0.2t times of v t , that is, v t is defined as an outlier. The selection of the multiple is related to the sampling time interval t. When the time interval t is 5 min, the multiple is 0.2t times. When the time interval is t / 2, the multiple is 0.1t times. When the physiological index is blood ketone and t is 5 min, it is judged through v t+1 and V t-1 to judge the value of v t When v t is greater than 0.2t times of V t-1 and v t+1 is greater than the absolute value of 0.2t times of v t , that is, v t is defined as an outlier. The selection of the multiple is related to the sampling time interval t. When the time interval t is 5 min, the multiple is 0.2t times. When the time interval is t / 2, the multiple is 0.1t times.
[0108]
[0109] When the value at that moment is identified as an outlier, the outlier needs to be deleted. The existence of outliers will greatly change the final prediction of the model;
[0110] Regarding data missing caused by various reasons, if there are too many missing values (when the missing data exceeds 40% of the overall data, it is not recommended to use it, or there is no data record for more than one hour continuously), it is not recommended to use this data. Divide the degree of data missing for the data with fewer missing values. Divide it into 3 levels according to the amount of missing data, namely low, medium, and high levels. When the missing value is between 1t and 3t, it is determined as a low level, and use v t = 2*v t-1 - v t-2 to fill the missing value of v t ; when the missing value is between 3t and 5t, it is identified as medium level, that is, use the AR autoregressive model for prediction, and fill the predicted value. The order p of the AR autoregressive model is determined by the missing data, p = 2*(3 - 5), and calculate and fill the predicted value according to the autoregressive coefficient equation; when the missing value is between 5t and 10t, since the human physiological index level conforms to the periodic change of time, that is, the physiological index value at time t has a certain similarity with the physiological index value at time t of the previous n days, that is, the predicted value V t of the current time t obtained by prediction through the AR autoregressive model and the value V day(t) at time t one day ago are averaged as the filling value y t of time t, that is, formula 1.8.
[0111] y t = mean(v day(t) , v t )(1.8)
[0112] The original physiological index data G obtained after the original processing of the collected original physiological index data G is pre_G.
[0113] In the filtering process of the preprocessing step, when using the detection device to collect physiological index data, it is usually affected by random noise. In order to improve the quality of the collected physiological index data, the Kalman filter is used to smooth the original physiological index data to obtain the filtered historical physiological index data, denoted as filter_G. The core of the Kalman filter is the state transition equation, which can not only process stationary signals but also non-stationary signals.
[0114] The entire filtering process of the Kalman filter is divided into two steps: the prediction process and the correction process. Prediction means estimating the state at the next moment through the state at the previous moment; correction means estimating the optimal state for the state estimate and state observation at the current moment. The initial value is set such that the observation value at the initial moment is set to the first value of the input data, and the observation deviation is 0.1. Specifically, in the implementation, the prediction process uses equations 1.9 and 1.10 to predict the value at the next moment from the estimated value at the previous moment, and equations 1.11, 1.12, and 1.13 correct the predicted value, so that the final output is the filtered data.
[0115]
[0116] P t - = FP t-1 F + Q (1.10)
[0117] K t = P t - H T (HP t - H T + R) -1 (1.11)
[0118]
[0119] P t = (I + K t H)P t (1.13)
[0120] Where: x represents the state matrix of the system, t represents a certain moment, - represents the estimated value, F is the state transition matrix, B is the control matrix, u t-1 represents the control quantity of the system at the previous moment. K is the Kalman gain, P is the covariance, I is the identity matrix, Q is the noise, H is the measurement matrix, Z is the observation matrix, R is the noise matrix, x t is the posteriori estimated value, that is, the output value.
[0121] For data segmentation in the model training step, if you want to use the CNN-LSTM model to predict physiological indicators, you need to divide the one-dimensional historical physiological indicator data obtained after filtering into the input form of supervised learning, which is convenient for sending the data into the model for training. Specifically, the one-dimensional time-series physiological indicator signal is segmented according to the set sampling interval and the input time data as the size of the sliding window, and the data of the prediction time is used as the sliding step.
[0122] The specific data segmentation schematic diagram of the sliding window method is asFigure 2 As shown. Assume that the historical physiological index data filter_G = [x i x i+1 ... x i+7 , the sliding window size W = 3, and the sliding step size S = 1; then the first group of data data1 = [x i x i+ 1x i+2 , and the first group of labels label = x i+3 ; the second group of data data2 = [x i+1 x i+2 x i+3 , and the second group of labels label = x i+4 . The number of sliding step sizes and label lengths is the same. Subsequent data are sequentially divided by sliding according to the window size and sliding step size. Specifically, when the physiological index is blood glucose, we use the sampling intervals t of 5 min and 30 min of historical physiological index data to obtain the data for the prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min, that is, the sliding window W = 6, the sliding step size S = 5, and the sliding step size S changes with the change of the prediction time; when using the sampling intervals t of 6 min and 60 min of historical physiological index data to obtain the data required for the prediction times of 6 min, 12 min, 18 min, 24 min, and 30 min, the sliding window W = 10 and the sliding step size = 6.
[0123] Prediction model construction. The structural schematic diagram of the CNN-LSTM model is as Figure 3As shown, the model is built using the Keras module in TensorFlow. The CNN-LSTM model includes an input layer, a hidden layer, and an output layer. Historical data is used as the input of the prediction model, and the predicted value is used as the output. First, the historical data is input into the CNN model. Through the convolutional layer Conv and the pooling layer Pooling, the feature extraction and dimensionality reduction of the data are achieved. The data processed by the CNN model is used as the input of the LSTM model. The LSTM model passes the input feature data through the forget gate (receiving the physiological index state unit information of the previous moment and deciding which parts to retain and forget), the input gate (determining which physiological index information at the current moment can be stored in the state unit), and the output gate (determining which parts of the physiological index information are output in the state unit), and continuously iterates on a large amount of input data to adjust its own parameters, enabling it to learn the temporal relationship between data from the feature data extracted by the CNN model, thereby effectively modeling the input data of the time series. Finally, the data trained by the CNN-LSTM model outputs the predicted value through the fully connected layer Dense. Specifically, in implementation, the specific parameters of this model consist of 2 convolutional layers, 2 pooling layers, 1 LSTM layer, and 1 fully connected layer Dense. The number of convolutional kernels in the 2 convolutional layers is 64 and 128 respectively, the size of the convolutional kernel is 2, 0 padding is used, and the activation function uses Relu; the pooling layer uses max pooling with a size of 2; the number of neurons in the LSTM layer is 128; 20% dropout is added before Dense to make 20% of the neurons inactive and prevent overfitting of the model. Finally, the Dense layer outputs, and the output dimension is the same as the number of prediction labels. The model uses the Adam optimizer and the mean squared error (MSE) as the loss function. The formula of the loss function MSE is shown in 1.14; the formula of the Relu activation function is shown in 1.15.
[0124]
[0125] Among them, n is the number of samples, x i is the true value, x i ^ is the predicted value.
[0126]
[0127] Based on the CNN-LSTM model, an attention mechanism is also added to the model. The purpose is to assign certain weights to the input objects that need to be concerned, to reflect the importance of the objects and obtain the required detailed information, and reduce the interference of redundant information. By assigning appropriate weights to key parameters and less or no weights to unimportant parameters, not only can the problem of a large number of parameters be solved, but also the recognition accuracy can be improved.
[0128] After adding the attention mechanism module to the LSTM layer, its structural diagram is as follows Figure 4 shown, where y i is the output of the i-th dimension after feature extraction. After summing the input y i through h, the feature F i is obtained. The obtained feature is passed through the softmax function to obtain the weight of this dimension, as shown in Equation 1.16, and the sum of the weights of each dimension is 1, as shown in Equation 1.17. Finally, using the weight α and the feature output y i to obtain the output Z of the attention module, as shown in Equation 1.18.
[0129]
[0130]
[0131]
[0132] It should be noted that the CNN model includes a convolutional layer, a pooling layer, and a fully connected layer. The convolutional layer extracts features from the input data, and the mathematical expression of the convolutional layer is as shown in 1.19.
[0133]
[0134] Among them: f represents the activation function, b is the bias, and w n,m is the weight corresponding to the position (n + m) of the convolutional kernel. N and M are the length and width of the convolutional kernel, and u represents the feature output by the previous layer.
[0135] The pooling layer downsamples the input data, reduces the dimension of the data, and thus reduces the number of parameters and the amount of computation. The fully connected layer maps the features after convolution and pooling to the network for the final output. Its expression is as shown in 1.20.
[0136] h(x) = f(w T x + b) (1.20)
[0137] Among them, h(x) is the output of the fully connected layer, f(g) represents the activation function, x is the input of the feature map of the previous layer, b is the bias, and w is the connection weight.
[0138] The specific structure of the CNN model includes 2 convolutional layers, 2 pooling layers, and 2 fully connected layers. The number of convolutional kernels in the 2 convolutional layers is 64 and 128 respectively, the size of the convolutional kernel is 2, 0 padding is used, and the activation function is Relu; the pooling layer uses max pooling with a size of 2; the number of neurons in the first fully connected layer is 128; the second fully connected layer outputs, and the output dimension is the same as the number of prediction labels. A dropout layer is added before the output layer to make 20% of the neurons inactive and prevent the model from overfitting. The model uses the Adam optimizer and mean squared error (MSE) as the loss function.
[0139] In the LSTM model, 3 gates are introduced, namely the input gate, the forget gate, and the output gate, as well as a memory cell c with the same shape as the hidden state to record additional information. Its schematic diagram is shown in Figure 5. The formulas for the three gates are as follows:
[0140] Input gate:
[0141] I t = σ(X t W xi + h t-1 W hi + b i )(1.21)
[0142] Forget gate:
[0143] F t = σ(X t W xf + h t-1 W hf + b f )(1.22)
[0144] Output gate:
[0145] O t = σ(X t W xo + h t-1 W ho + b o )(1.23)
[0146] Among them, h t-1 is the hidden state at the previous time step, X t is the input, b is the bias, W is the weight, and σ is the activation function.
[0147] The specific structure of the LSTM model includes two LSTM layers and a fully connected layer. The number of neurons in the two LSTM layers is 64 and 128 respectively, and the activation function is Relu; the fully connected layer is used for output, and the output dimension is the same as the number of prediction labels. The model uses the Adam optimizer and the mean squared error (MSE) as the loss function.
[0148] Model training steps: Divide the filtered data filter_G into two parts, that is, 80% as the training set and 20% as the test set. Divide the training set and the test set according to the size of the sliding window W and the sliding step S, and the corresponding labels are set according to the prediction time / t. Specifically, the prediction time is 30 minutes, t is 5 minutes, and the corresponding label is 6. Input the training set with the divided data and labels into the model for training, set the number of epochs to 500 times, and record the running time of the model. After training, a trained model M is obtained. At the same time, input the test set data into the model M to obtain the prediction results, and obtain the results at the prediction times of 5 minutes, 10 minutes, 15 minutes, 20 minutes, 25 minutes, and 30 minutes. The accuracy of the model M prediction is evaluated using the mean absolute error (MAE), root mean square error (RMSE), root mean square percentage error (RMSPE), mean squared error (MSE), and mean absolute percentage error (MAPE). The formulas for MAE, RMSE, RMSPE, MSE, and MAPE are shown in 1.24, 1.25, 1.26, 1.27, and 1.28.
[0149]
[0150]
[0151]
[0152]
[0153]
[0154] Among them, n and m are the number of samples, x i is the true value, and x i ^ is the predicted value.
[0155] Alarm steps, which play a warning role for high or low physiological indicators. Specifically, through data division, the prediction results at 5 minutes, 10 minutes, 15 minutes, 20 minutes, 25 minutes, and 30 minutes can be obtained respectively through the model. The warning is achieved through the prediction results, informing the patient in advance of the possible fluctuations in physiological indicators at the next moment. Specifically, it can be informed 5 minutes in advance, giving the patient a certain preparation time to deal with high or low physiological indicators. The warning is realized by judging the prediction data, which requires the accuracy of the prediction data. Only when the prediction data is accurate enough can the alarm be accurate and play a good warning role for the patient, facilitating subsequent adjustment or treatment of physiological indicators. Based on the accuracy requirements of the alarm, two ranges are set for the alarm, namely the first extreme range and the second ordinary range. By setting a dual range for the alarm and strictly requiring the prediction data to meet the confirmation conditions for the alarm requirements, the purpose of reducing false alarms and missed alarms is achieved.
[0156] The first extreme range means that when the predicted physiological indicator value or the real-time collected physiological indicator value exceeds this range, an immediate alarm is triggered. For example, the extreme range of blood glucose is set to 3 - 27.8 mmol / L, that is, when the predicted blood glucose value or the real-time collected blood glucose value is lower than 3 mmol / L or higher than 27.8 mmol / L, an immediate alarm is triggered; the extreme range of blood ketone is 1.6 mmol / L, that is, when the predicted blood ketone value or the real-time collected blood ketone value is higher than 1.6 mmol / L, an immediate alarm is triggered; the extreme range of uric acid is 450 umol / L, that is, when the predicted uric acid value or the real-time collected uric acid value is higher than 450 umol / L, an immediate alarm is triggered. The extreme range can be adjusted to a range suitable for the user according to the user's age, health status, medical advice, etc.
[0157] The second general range is set specifically considering issues such as the age, disease severity, and presence of complications of different patients. Four modes are set, namely the child mode, adolescent mode, adult mode, and elderly mode, and each mode can be further divided into a normal mode and a diseased mode. For example, when the physiological index is blood glucose, four modes are set, namely the child mode, adolescent mode, adult mode, and elderly mode. The four modes can select different modes and set corresponding blood glucose control standard thresholds according to their own disease severity and the doctor's advice during the device mode stage. For example, in the child and adolescent modes, considering that children and adolescents need to balance blood glucose control and growth and development, the blood glucose levels on an empty stomach and 2 hours after a meal can be adjusted appropriately. For example, the fasting blood glucose can be 5 - 10 mmol / L, and the blood glucose 2 hours after a meal can be less than 10 mmol / L, or the high and low blood glucose thresholds can be set according to the blood glucose control range given by the doctor. The reason is that although the standard blood glucose range is 3.9 - 6.1 mmol / L on an empty stomach and the blood glucose concentration 2 hours after a meal is lower than 7.8 mmol / L, doctors will also give a relatively reasonable blood glucose control range according to the age, duration of the disease, and severity of different patients. The purpose of the warning is also to control the blood glucose value within a reasonable and desired blood glucose control range, and issue a warning for blood glucose values exceeding this range, facilitating the patient's understanding of their own blood glucose and timely taking corresponding countermeasures. The same applies to blood ketone and uric acid, which need to be adjusted according to specific circumstances.
[0158] Nocturnal hypoglycemic reactions are very harmful to diabetic patients. If diabetic patients experience hypoglycemia at night, it is very easy to induce acute cardio-cerebral diseases. If not discovered in time, it may lead to the death of the patient due to untimely rescue and treatment. The occurrence time of nocturnal hypoglycemia is generally from 1 am to 4 am. Therefore, key monitoring is carried out on the blood glucose prediction data from 1 am to 4 am. During this time period, if the blood glucose drops by more than 1 mmol / L within 30 minutes, it is recorded and a hypoglycemia risk is displayed; if the blood glucose drops by more than 2 mmol / L within 30 minutes, an alarm is issued and a relatively high hypoglycemia risk is recorded, or when the blood glucose value is lower than 2.8 mmol / L, an alarm is issued and hypoglycemia is recorded, and sugar is supplemented in a timely manner. For patients injecting insulin, the injection amount is reduced before going to bed.
[0159] Meanwhile, strict control is also imposed on the requirements for alarm. When the predicted physiological index values are judged based on three consecutive sampling intervals, if the physiological index values in three consecutive sampling intervals are all higher than the physiological index control range, it is a high physiological index, and a high physiological index alarm is issued; if the physiological index values in three consecutive sampling intervals are all lower than the physiological index control range, it is a low physiological index, and a low physiological index alarm is issued. If two of the physiological index values in three consecutive sampling intervals are high physiological index and one is low physiological index, considering the possibility of misjudgment, this situation is calibrated according to the fourth value. If the fourth value is determined to be a high physiological index, a high physiological index alarm is issued. If the fourth value is still detected as a low physiological index, the fifth value is needed for determination, and the maximum number of judgment data is 5. When the fifth value is used for judgment, the majority judgment result of the previous 5 values is used as the final result for alarm to prevent misjudgment from causing unnecessary impact on the patient's body due to incorrect adjustment of physiological index values.
[0160] The CNN-LSTM model based on normal sampling is used to predict blood glucose data, and the prediction results at prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min are obtained; the single CNN model and LSTM model based on normal sampling are used to predict blood glucose data, and the prediction results at prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min are obtained. The prediction result curve is as Figure 6-18 shown. The CNN-LSTM model with or without attention mechanism based on normal sampling is used to predict blood glucose data, and the prediction results at prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min are obtained, as Figure 19-20 shown; the CNN-LSTM model based on normal sampling or dynamic sampling is used to predict blood glucose data, and the prediction results at prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min are obtained, as Figure 23-24 shown; the CNN-LSTM model based on normal sampling or dynamic sampling and attention mechanism is used to predict blood glucose data, and the prediction results at prediction times of 5 min, 10 min, 15 min, 20 min, 25 min, and 30 min are obtained, as Figure 25-26As shown. Specifically, normal sampling (Normal) means that the sampling frequency s is fixed at 5 minutes per time and the sampling time interval t is fixed at 5 minutes from start to end; dynamic sampling (Dynamic) means that in the initial state, the sampling frequency s is 5 minutes per time and the sampling time interval t is 5 minutes. When the physiological index reaches the threshold of the rising state or the falling state, the sampling frequency is adjusted to be greater than 2.5 minutes per time, and the sampling interval is adjusted to 2.5 minutes. When the physiological index reaches the stable state, the sampling frequency is adjusted to 5 minutes per time, and the sampling interval is adjusted to 5 minutes, and the original physiological index data collected at the low sampling frequency is processed by inserting data to form the original physiological index data with a time interval of 2.5 minutes per time.
[0161] Based on the mean absolute error (MAE), root mean square error (RMSE), root mean square percentage error (RMSPE), mean square error (MSE), and mean absolute percentage error (MAPE), the predicted blood glucose results of each model at each prediction time based on normal sampling (Normal) and dynamic sampling (Dynamic) are evaluated, and the results are shown in Tables 1 to 6.
[0162] Table 1 Predicted results of the subjects at 5 minutes under different models
[0163]
[0164] Table 2 Predicted results of the subjects at 10 minutes under different models
[0165]
[0166] Table 3 Predicted results of the subjects at 15 minutes under different models
[0167]
[0168] Table 4 Predicted results of the subjects at 20 minutes under different models
[0169]
[0170] Table 5 Predicted results of the subjects at 25 minutes under different models
[0171]
[0172] Table 6 Predicted results of the subjects at 30 minutes under different models
[0173]
[0174] Looking at each row in Tables 1 to 6, according to the evaluation metrics of MAE, RMSE, RMSPE, MSE, and MAPE, the evaluation metrics of the conventional sampling models from CNN, LSTM to CNN-LSTM are getting smaller or showing a decreasing trend, indicating that the difference between the true value and the predicted value of the CNN, LSTM, and CNN-LSTM models is decreasing step by step. The comparison of MSE is as Figure 21 shown. At the same time, it shows that the prediction ability of the CNN, LSTM, and CNN-LSTM models is improving step by step, indicating that the CNN-LSTM model has excellent prediction effects and outstanding effects at different prediction times. On this basis, based on the dynamic sampling model, its MAE, RMSE, RMSPE, MSE, and MAPE evaluation metrics are all lower than those of the conventional sampling model. The comparison of MSE is as Figure 22 shown, indicating that the prediction ability of the CNN, LSTM, and CNN-LSTM models based on dynamic sampling is further improved compared with the conventional sampling model.
[0175] According to the mean absolute error (MAE), root mean square error (RMSE), root mean square percentage error (RMSPE), mean square error (MSE), and mean absolute percentage error (MAPE), the predicted blood glucose results of the CNN-LSTM models based on dynamic sampling (Dynamic) with or without attention mechanism for a prediction time of 30 min are evaluated, and the results are shown in Table 7.
[0176] Table 7 Effects of adding attention to the CNN-LSTM model for the subjects
[0177]
[0178]
[0179] While the CNN-LSTM model demonstrates excellent performance ability, adding an attention module to this model, the prediction results are as Figure 19-20 and Figure 25-26 shown. It can be seen from the local enlarged view that the CNN-LSTM prediction results based on conventional sampling or dynamic sampling and attention mechanism are all superior to CNN-LSTM. As can be seen from Table 7, although the CNN-LSTM based on dynamic sampling is already excellent, after adding the attention module, its evaluation metrics are further reduced, and the difference between the true value and the predicted value is further reduced. The prediction of the CNN-LSTM model based on dynamic sampling and attention mechanism has been further optimized, which can further improve the accuracy of physiological index prediction.
[0180] The above specific embodiments are used to explain the present invention rather than limit the present invention. Any modifications and changes made to the present invention within the spirit and scope of the claims of the present invention fall within the protection scope of the present invention.
Claims
1. A CNN-LSTM physiological index prediction method based on dynamic sampling and attention mechanism, characterized in that It includes the following steps: Data acquisition: At the initial state, the original physiological index data is acquired at a sampling frequency of s and a sampling time interval of t. When it is determined that the physiological index reaches the threshold, the sampling frequency is updated to s' and the sampling time interval is updated to t' to acquire the original physiological index data; Original processing: The original physiological index data is processed by inserting data to form the original physiological index data with a fixed time interval; Preprocessing: The original physiological index data is smoothed to obtain the filtered historical physiological index data; Build a CNN-LSTM model based on the attention mechanism; Model training: The historical physiological index data is segmented into the input and output data of the CNN-LSTM model by the sliding window method. The N historical physiological index data with a sampling time interval of t' are used as the input, and the M future physiological index values with a time interval of t are used as the output; Predict the physiological index value: The data to be tested is input into the trained CNN-LSTM model based on the attention mechanism to obtain the predicted physiological index value.
2. The physiological index prediction method according to claim 1, wherein: Let the current moment be \(t\), and take the physiological index values \(v\) at at least three time points respectively t-1 , \(v\) t , \(v\) t+1 . Take the differences between every two physiological index values to obtain \(x\) t and \(x\) t+1 ; When x is monitored t and x t+1 the product is greater than or equal to Y 2 t 2 , it is determined that the physiological index reaches the first threshold, and the sampling frequency is adjusted to s' greater than s and the sampling time interval is adjusted to t' less than t to collect the original physiological index data; Or when x is monitored t and x t+1 the product is less than 0 and x t+1 is less than the absolute value of 0.5Yt, it is determined that the physiological index reaches the second threshold, and the sampling frequency is adjusted to s' greater than s and the sampling time interval is adjusted to t' less than t to collect the original physiological index data; Where Y is the maximum reasonable change of the physiological index per minute.
3. The physiological index prediction method according to claim 2, wherein: When x is monitored t and x t+1 the product is less than 0 and x t+1 is greater than or equal to the absolute value of 0.5Yt, it is determined that the physiological index reaches the third threshold, and the sampling frequency is adjusted to s' less than or equal to s and the sampling time interval is adjusted to t' greater than or equal to t to collect the original physiological index data; or when x t and x t+1 the product is greater than or equal to 0 and less than Y 2 t 2 at this time, it is determined that the physiological index reaches the fourth threshold, and the sampling frequency is adjusted to s' less than or equal to s and the sampling time interval is adjusted to t' greater than or equal to t to collect the original physiological index data.
4. The physiological index prediction method according to claim 2 or 3, characterized in that: When the physiological index is blood glucose, Y is 0.06 - 0.1 mmol / L. When it is determined that the physiological index reaches the first or second threshold, the sampling frequency s' is 2s and the sampling time interval t' is t / 2; when it is determined that the physiological index reaches the third or fourth threshold, the sampling frequency s' is s / 2 and the sampling time interval t' is 2t; or when it is determined that the physiological index reaches the third or fourth threshold, the sampling frequency s' is s and the sampling time interval t' is t.
5. The physiological index prediction method according to claim 1 or 2 or 3, characterized in that: In the preprocessing step, the original physiological index data obtained after the original data processing is smoothed by Kalman filtering to obtain the filtered historical physiological index data; The Kalman filtering process includes the following steps: Prediction step: Estimate the state at the next moment through the state at the previous moment. The specific formula is P t - = FP t-1 F + Q(1.10) Correction step: Estimate the optimal state for the state at the current moment. The specific formula is K t = P t - H T (HP t - H T + R) -1 (1.11) P t =(I + K t H)P t (1.13) Among them, x represents the state matrix of the system, t represents a certain moment, - represents the estimated value, F is the state transition matrix, B is the control matrix, u t-1 represents the control quantity of the system at the previous moment, K is the Kalman gain, P is the covariance, I is the identity matrix, Q is the noise, H is the measurement matrix, Z is the observation matrix, R is the noise matrix, x t is the posteriori estimated value, that is, the output value.
6. The physiological index prediction method according to claim 1, wherein: In the original processing step, the original physiological index data is also processed for outliers. After removing the outliers, the missing intervals are classified according to the amount of data missing and filled respectively.
7. The physiological index prediction method according to claim 1, wherein: The steps for building the model are as follows: Input the historical physiological index data into the CNN model. Through the convolutional layer and the pooling layer, feature extraction and dimensionality reduction of the data are realized; The data processed by the CNN model is used as the input of the LSTM model. The LSTM model passes the input feature data through the forget gate, input gate and output gate, and iteratively adjusts the parameters of the input data, so that it can learn the time relationship between the data from the feature data extracted by the CNN model and model the input data of the time series; The data trained by the CNN-LSTM model outputs the predicted value through the fully connected layer.
8. The physiological index prediction method according to claim 1 or 7, characterized in that: The model parameters consist of two convolutional layers, two pooling layers, one LSTM layer and one fully connected layer Dense; the number of convolutional kernels in the two convolutional layers are 64 and 128 respectively, the size of the convolutional kernel is 2, 0 padding is used, and the activation function uses Relu; the pooling layer uses max pooling with a size of 2; The number of neurons in the LSTM layer is 128; 20% dropout is added before Dense to deactivate 20% of the neurons, and finally the Dense layer outputs with the output dimension being the same as the number of predicted labels.
9. The physiological index prediction method according to claim 1, wherein: An attention mechanism is added to the CNN-LSTM model, and the formula for obtaining the dimensional weights is and the sum of the weights of each dimension is 1.
10. The physiological index prediction method according to claim 1, wherein: It further includes an alarm step, which is at least provided with a first limit range and a second normal range. The first limit range is the range exceeding the normal physiological indexes, and the second normal range at least includes the ranges of children and adolescents, adults and the elderly.
11. A CNN-LSTM physiological index prediction system based on dynamic sampling and attention mechanism, characterized in that used to implement the physiological index prediction method according to any one of claims 1 to 10, including: a data acquisition unit, which, in the initial state, acquires the original physiological index data at a sampling frequency s and a sampling time interval t, and when it is judged that the physiological index reaches the threshold, updates the sampling frequency to s' and the sampling time interval to t' to acquire the original physiological index data; an original processing unit, which performs insertion data processing on the original physiological index data to form the original physiological index data with a fixed time interval; a preprocessing unit, which performs smoothing processing on the original physiological index data to obtain the filtered historical physiological index data; a CNN-LSTM model unit based on the attention mechanism; a model training unit, which divides the historical physiological index data into the input and output data of the CNN-LSTM model by using the sliding window method, takes N pieces of historical physiological index data with a sampling time interval of t' as the input, and M future physiological index values with a time interval of t as the output; a prediction unit, which inputs the data to be tested into the trained CNN-LSTM model based on the attention mechanism to obtain the predicted physiological index value.