Blood glucose fluctuation prediction method based on historical data

By collecting and processing multi-dimensional data, constructing a blood glucose fluctuation feature matrix and optimizing the prediction model, and generating personalized reports, the problems of insufficient data coverage and poor adaptability to individual differences in existing technologies are solved, achieving more accurate blood glucose fluctuation prediction and management.

CN121306546AInactive Publication Date: 2026-01-09THE SECOND HOSPITAL OF HEBEI MEDICAL UNIV
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202511469943.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-15
Publication Date
2026-01-09
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing blood glucose prediction methods based on historical data suffer from incomplete data coverage, short data collection periods, and a lack of understanding of the influence of lifestyle habits and blood glucose intervention factors, resulting in large prediction biases and an inability to adapt to individual differences, thus leading to insufficient prediction accuracy.

Method used

By collecting users' blood glucose monitoring data, daily behavior data, physiological status data, and medical intervention data, we perform timeline alignment and outlier cleaning to extract the basic and related features of blood glucose fluctuations, construct a multi-dimensional feature matrix, use a dynamic prediction model based on the Transformer architecture to generate blood glucose fluctuation prediction curves, and optimize the model through deviation analysis to generate personalized reports.

Benefits of technology

It improves the accuracy of blood glucose fluctuation prediction, provides refined information and personalized suggestions, and solves the problems of insufficient data coverage, shallow feature mining, simple model and poor adaptability to individual differences, thus achieving more precise blood glucose management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121306546A_ABST
    Figure CN121306546A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of blood glucose prediction, in particular to a blood glucose fluctuation prediction method based on historical data. The method comprises the following steps: acquiring corresponding historical blood glucose monitoring data, daily behavior data, physiological status data and medical intervention data of a user, performing time axis alignment and abnormal value cleaning treatment, and extracting basic features and associated influence features corresponding to blood glucose fluctuation; performing space-time dimension fusion on the basic features and the associated influence features, and generating a blood glucose fluctuation prediction curve of the user in a future preset time period; performing comparative analysis on the blood glucose fluctuation prediction curve and actual blood glucose monitoring data of the user, calculating a prediction deviation degree and a trend goodness of fit, and generating a corresponding deviation analysis result; feature weight distribution of the dynamic prediction model is optimized based on the deviation analysis result, and a personalized blood glucose fluctuation prediction report is generated and comprises a risk early warning threshold value and an intervention suggestion triggering condition. According to the method, prediction efficiency and personalized management of blood glucose fluctuation can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blood glucose prediction, and in particular to a blood glucose fluctuation prediction method based on historical data. BACKGROUND

[0002] In recent years, with the continuous rise of global diabetes prevalence, patients have higher requirements for the forward-looking, individualized and precise blood glucose management. Blood glucose fluctuation is not only directly related to the risk of complications of diabetes (such as neuropathy and kidney disease), but also dynamically affected by multiple factors such as diet, exercise, medication, sleep, etc. The traditional management mode relying on real-time blood glucose detection or single time point data has been difficult to realize the early prediction of blood glucose trend, and cannot provide timely intervention guidance for patients.

[0003] At present, some blood glucose prediction methods based on historical data have been proposed. These methods mostly collect short-term blood glucose monitoring data (such as 1-7 days) of patients, combine simple time series models (such as moving average, ARIMA model) to predict blood glucose values in the future hours, and then give early warning according to fixed blood glucose thresholds. However, the existing methods are insufficient in the dimension coverage and depth mining of historical data, and are easily affected by factors such as short data collection period, lack of life habits and blood glucose intervention, which may lead to large deviation between predicted results and actual blood glucose fluctuation, causing delay in intervention opportunity. At the same time, the adaptability of traditional models to individual differences is weak, and they can only make predictions based on general algorithms, which is difficult to cover the characteristic differences of different patients and the blood glucose change needs in complex life scenes, thereby reducing the accuracy of blood glucose fluctuation prediction. SUMMARY

[0004] Therefore, it is necessary to provide a blood glucose fluctuation prediction method based on historical data to solve at least one of the above technical problems.

[0005] To achieve the above-mentioned purpose, a blood glucose fluctuation prediction method based on historical data comprises the following steps:

[0006] Step S1: obtaining historical blood glucose monitoring data, daily behavior data, physiological state data and medical intervention data corresponding to a user, and performing time axis alignment and outlier cleaning processing on various historical data to generate a standardized blood glucose related data set;

[0007] Step S2: extracting basic features and associated influence features corresponding to blood glucose fluctuation based on the standardized blood glucose related data set, wherein the basic features include blood glucose mean shift degree, intraday fluctuation amplitude and postprandial peak delay time, the associated influence features include the correlation coefficient of dietary glycemic index and blood glucose response, the dynamic relationship between exercise intensity and blood glucose drop, and the matching degree of drug action time and blood glucose regulation; performing spatio-temporal dimension fusion on the basic features and the associated influence features to construct a blood glucose fluctuation multi-dimensional feature matrix;

[0008] Step S3: Based on the blood glucose fluctuation multi-dimensional feature matrix, a dynamic prediction model is constructed to learn the mapping relationship between different feature combinations and blood glucose fluctuation trends through the model, and a blood glucose fluctuation prediction curve for the user in a future preset period is generated, which contains blood glucose peak, valley occurrence time and fluctuation amplitude change rate;

[0009] Step S4: The blood glucose fluctuation prediction curve is compared and analyzed with the user's actual blood glucose monitoring data, the prediction deviation degree and trend coincidence degree are calculated to generate the corresponding deviation analysis result; based on the deviation analysis result, the feature weight distribution of the dynamic prediction model is optimized to generate a personalized blood glucose fluctuation prediction report, which contains risk warning threshold and intervention suggestion trigger condition.

[0010] Further, step S1 includes the following steps:

[0011] Step S11: Collect the user's corresponding historical blood glucose monitoring data through a continuous blood glucose monitoring device to obtain the blood glucose value and detection timestamp at each monitoring time; collect daily behavior data through a smart wearable device, including diet type, food intake, exercise type, exercise intensity and sleep duration; collect physiological state data through a medical detection device, including daily weight, resting heart rate, cortisol level and insulin secretion; collect medical intervention data through an electronic medical record system, including types of hypoglycemic drugs, medication frequency, insulin injection dose and adjustment time point;

[0012] Step S12: Standardize the format of the collected historical data to convert the timestamp to UTC time format, convert the numerical data to a unified unit, and convert the text data to an encoded format;

[0013] Step S13: Use the Isolation Forest algorithm to identify outliers in various historical data, including instrument error values in blood glucose monitoring data, logical contradiction records in behavior data, and jump values in physiological data; use time series interpolation method to complete the missing data, and generate filling values for the missing period based on the behavior pattern and blood glucose change rule of similar days;

[0014] Step S14: Align and integrate the processed historical data according to the time axis to construct a standardized blood glucose related data set containing time dimension, data type dimension and feature index dimension, where each record contains multi-source data feature values at the corresponding time point.

[0015] Further, step S2 includes the following steps:

[0016] The blood glucose mean value and the standard deviation in a preset period are calculated based on the blood glucose monitoring data in the history of the standardized blood glucose related data set, and the blood glucose mean value drift degree is generated by a mean value sliding window calculation to represent the change trend of the blood glucose baseline; the difference between the maximum value and the minimum value of the blood glucose in a day is calculated, and the intra-day fluctuation amplitude parameter is generated in combination with the time interval of the occurrence time; the postprandial peak value delay time is generated by extracting the time difference between the postprandial blood glucose peak value and the meal time;

[0017] The blood glucose mean value drift degree, the intra-day fluctuation amplitude and the postprandial peak value delay time are taken as the blood glucose fluctuation basic features to construct a basic feature vector;

[0018] In combination with the daily behavior data and the blood glucose monitoring data, the correlation degree between the glycemic index of different foods and the postprandial blood glucose increase is calculated through the Pearson correlation coefficient to generate a diet-blood glucose correlation coefficient; based on the exercise intensity data and the post-exercise blood glucose change amount, a nonlinear regression model is used to fit the dynamic relationship curve of exercise intensity and blood glucose decrease; according to the medication time, dose data and blood glucose change curve, the matching degree parameter of drug concentration half-life and blood glucose regulation effect is calculated;

[0019] The diet-blood glucose correlation coefficient, the exercise-blood glucose dynamic relationship curve and the drug-blood glucose matching degree parameter are taken as the correlation influence features to construct a correlation feature vector;

[0020] The basic feature vector and the correlation feature vector are fused through a spatio-temporal attention mechanism to generate a blood glucose fluctuation multi-dimensional feature matrix containing a time decay factor and a feature importance weight.

[0021] Further, the blood glucose mean value drift degree generated by the mean value sliding window calculation comprises:

[0022] The length and sliding step of the time sliding window are set, and the window parameters are determined based on the time granularity of the standardized blood glucose related data set;

[0023] The historical blood glucose monitoring data is sequentially included in the time sliding window in chronological order, the blood glucose mean value and the median in each time sliding window are calculated, and a window mean value sequence is generated;

[0024] The window mean value sequences of adjacent windows are subjected to difference operation to obtain the mean value change amount between windows, and the mean value change rate is calculated in combination with the window time interval;

[0025] The mean value change rate is filtered by an exponential smoothing method to eliminate short-term fluctuation interference and retain long-term trend components;

[0026] The processed mean value change rate and the reference mean value are normalized to generate the blood glucose mean value drift degree, wherein a positive value indicates that the blood glucose baseline moves up, and a negative value indicates that the blood glucose baseline moves down.

[0027] Further, the calculation of the matching degree parameter of the drug concentration half-life and the blood glucose regulation effect according to the medication time, dose data and blood glucose change curve comprises:

[0028] Based on the medication time and dose data in the medical intervention data, a drug metabolism kinetics model is constructed, and the absorption, distribution, metabolism and excretion of the drug in the body are simulated through the drug metabolism kinetics model, and the drug concentration prediction value at different time points is calculated, and a drug concentration-time curve is generated;

[0029] The drug concentration half-life parameter is extracted from the drug concentration-time curve, specifically the time required for the drug concentration to drop to half of the initial value, and the effective action period of the drug is determined in combination with the drug metabolism kinetics characteristics;

[0030] The medication time and the blood glucose change curve are aligned on the time axis, and the blood glucose change characteristics in a preset period after medication are extracted, including the blood glucose peak drop, the blood glucose curve slope change rate and the blood glucose regression time to the baseline level;

[0031] The correlation function of drug concentration and blood glucose regulation effect is constructed, the drug concentration half-life is taken as the input variable, the blood glucose peak drop, the blood glucose curve slope change rate and the blood glucose regression time are taken as the output variables, and the parameters of the correlation function are obtained through nonlinear fitting;

[0032] The deviation value of the theoretical blood glucose regulation effect corresponding to the drug concentration half-life and the actual blood glucose change characteristics is calculated, and the matching degree parameter of the drug concentration half-life and the blood glucose regulation effect is generated through deviation normalization processing, and the matching degree parameter takes the value range of 0-1.

[0033] Further, the construction of the correlation function of drug concentration and blood glucose regulation effect, taking the drug concentration half-life as the input variable, and the blood glucose peak drop, the blood glucose curve slope change rate and the blood glucose regression time as the output variable, and obtaining the parameters of the correlation function through nonlinear fitting comprises:

[0034] The input variable and the output variable corresponding to the correlation function are defined, the input variable is defined as the drug concentration half-life , the output variable includes the blood glucose peak drop , the blood glucose curve slope change rate and the blood glucose regression time , and the corresponding multi-output nonlinear correlation function model is constructed; wherein, , , is the main coefficient of the correlation function, , , is the decay / growth coefficient, , , is an adjustment coefficient, , , is a reference offset;

[0035] Based on the obtained drug concentration half-life, blood glucose peak reduction, blood glucose curve slope change rate and blood glucose regression time, a training data set is constructed, wherein each sample contains a set of corresponding values, wherein from the drug concentration-time curve extraction result, from the blood glucose change curve analysis result after taking medicine;

[0036] A multi-objective particle swarm optimization algorithm is used to perform nonlinear fitting on the correlation function parameters, and the weighted mean square error of the predicted value and the actual sample value is minimized as the objective function, and the expression corresponding to the objective function is specifically:

[0037] ;

[0038] wherein, is the number of samples, , , is the predicted value of the correlation function, , , is the actual value of the sample, , , is the error weight of each output variable, and ;

[0039] An iteration termination condition is set, and when the objective function value is less than a preset error threshold or the number of iterations reaches a maximum threshold, the parameter optimization is stopped, and the optimal parameter combination is output ;

[0040] The optimal parameter combination is substituted into the multi-output nonlinear correlation function model, and the construction of the drug concentration and blood glucose regulation effect correlation function is completed, and through the function, the corresponding blood glucose peak reduction, blood glucose curve slope change rate and blood glucose regression time prediction value can be directly calculated from any drug concentration half-life .

[0041] Further, step S3 includes the following steps:

[0042] The blood glucose fluctuation multi-dimensional feature matrix is divided into a training sample set and a verification sample set in chronological order, wherein the training sample set contains historical feature data and corresponding subsequent blood glucose fluctuation results, and the verification sample set is used for model performance evaluation;

[0043] The dynamic prediction model based on the Transformer architecture includes an input layer, a multi-head self-attention layer, a feature interaction layer, and an output layer. The input layer receives a multi-dimensional feature matrix of blood glucose fluctuations. The multi-head self-attention layer captures the dependency of features at different time points. The feature interaction layer fuses basic features and related influence features through a gating mechanism. The output layer generates a blood glucose fluctuation curve for the future time period through a time series prediction head.

[0044] The dynamic prediction model is trained using an adaptive learning rate optimization algorithm to adjust the model parameters by minimizing the mean square error between the predicted curve and the actual blood glucose curve. An early stopping mechanism is used to prevent overfitting of the model.

[0045] The trained dynamic prediction model is used to generate a blood glucose fluctuation prediction curve for a future predetermined time period. The prediction curve includes blood glucose prediction values, prediction confidence intervals, and feature contribution indicators at each time point.

[0046] Further, step S4 includes the following steps:

[0047] The blood glucose fluctuation prediction curve is aligned with the actual blood glucose monitoring data of the user at the same time point. The absolute error and relative error between the predicted value and the actual value at each corresponding time point are calculated to generate an error sequence.

[0048] The prediction bias degree is calculated based on the error sequence, including the mean absolute error, root mean square error, and maximum error value. The trend consistency of the predicted curve and the actual curve is calculated using the dynamic time warping algorithm.

[0049] The bias threshold and consistency threshold are set. When the prediction bias degree exceeds the bias threshold or the trend consistency is lower than the consistency threshold, the model optimization mechanism is triggered to adjust the weight distribution of the related influence features in the dynamic prediction model.

[0050] Based on the optimized dynamic prediction model, the blood glucose fluctuation prediction curve is regenerated. The risk warning threshold for abnormal blood glucose fluctuation is determined based on the user's physiological state data and medical intervention data. A personalized blood glucose fluctuation prediction report is generated, including the risk warning threshold and the intervention suggestion trigger condition.

[0051] Further, the trend consistency of the predicted curve and the actual curve calculated by the dynamic time warping algorithm includes:

[0052] The blood glucose fluctuation prediction curve is represented as a time series The actual blood glucose monitoring curve is represented as a time series where and are the number of time points of the predicted curve and the actual curve, respectively.

[0053] Build × Distance matrix , where matrix elements Indicates the predicted sequence number The point and the actual sequence Euclidean distance between points;

[0054] Find the source using dynamic programming algorithm arrive The optimal path is the one with the minimum sum of distances along the path, where the path constraints satisfy the conditions of monotonicity and continuity.

[0055] Calculate the ratio of the total distance of the optimal path to the theoretical maximum distance, and convert it into a trend fit S = 1 - (total distance of the optimal path / theoretical maximum distance);

[0056] The trend consistency is evaluated in segments. When S is greater than or equal to the preset high consistency threshold, the predicted trend is considered highly reliable. When S is between the high and low consistency thresholds, the predicted trend is considered basically reliable. When S is less than the preset low consistency threshold, the predicted trend needs to be corrected.

[0057] Furthermore, the method of finding the source from the dynamic programming algorithm... arrive The optimal paths include:

[0058] Initialize the cumulative distance matrix ,in Indicates from arrive The minimum cumulative distance, ;

[0059] The corresponding cumulative distance matrix elements are calculated using a recursive formula, and a trend constraint factor is introduced to correct these elements. Specifically, the correction process involves calculating the predicted sequence at points... Local trends The actual sequence is at point Local trends The trend similarity function is used to calculate the trend matching degree between two points. ,in To minimize the value and avoid a denominator of zero; construct a trend constraint factor. ,in The basic weighting coefficients are used; simultaneously, the recursive calculation formula for the cumulative distance matrix is ​​modified as follows: By enhancing the matching priority of point pairs with similar local trends through trend constraint factors, the optimal path can better reflect the actual trend changes in blood glucose fluctuations.

[0060] from Start tracing the optimal path in reverse, when At that time, the path point is When equal to At that time, the path point is When equal to At that time, the path point is ;

[0061] Record the coordinates of all path points to form a complete optimal matching path;

[0062] Calculate all on the optimal path The sum of these values ​​serves as a measure of the overall distance between the predicted curve and the actual curve.

[0063] The beneficial effects of this invention are:

[0064] The proposed method for predicting blood glucose fluctuations based on historical data, compared to existing technologies, offers several advantages. Firstly, by collecting and standardizing multi-dimensional historical data, it effectively addresses the weaknesses in existing methods due to their limited data dimensions and short collection periods. Existing methods rely solely on short-term blood glucose data (1-7 days), neglecting key influencing factors such as daily behavior, physiological state, and medical interventions. This incomplete data coverage easily leads to prediction bias. Secondly, by comprehensively collecting blood glucose monitoring data, daily behavior data, physiological state data, and medical intervention data, the method ensures that the data dimensions cover the core influencing factors of blood glucose fluctuations. Then, through timeline alignment and outlier cleaning, a standardized dataset is generated. This process transforms the data from "fragmented short-term records" into "complete long-term correlated data," providing a comprehensive and reliable foundation for subsequent feature extraction and avoiding prediction bias caused by missing or abnormal data, thus laying a data foundation for accurate prediction. Thirdly, by extracting multi-dimensional features and performing spatiotemporal fusion, the method solves the problems of insufficient data depth mining and lack of feature correlation analysis in existing methods. Existing solutions simply use blood glucose values ​​as features, failing to explore the intrinsic patterns of blood glucose fluctuations (such as mean drift and postprandial peak delay) and their correlation with external factors (such as the impact of dietary glycemic index on blood glucose), resulting in insufficient feature representativeness. This step first extracts basic features (blood glucose mean drift reflects long-term trends, intraday fluctuation amplitude reflects short-term changes, and postprandial peak delay time correlates with digestion and absorption patterns) to capture the core attributes of blood glucose fluctuations. Then, it extracts correlated features (dietary glycemic index and blood glucose response coefficient reflect the impact of diet, the relationship between exercise intensity and blood glucose reduction reflects the effect of exercise, and drug efficacy and regulation matching degree correlate with the effect of medical intervention), establishing the correlation logic between external factors and blood glucose. Through spatiotemporal fusion, a multi-dimensional feature matrix is ​​constructed, which can fully explore the patterns and correlations behind the data, filling the gaps in existing solutions' "shallow feature mining and weak correlations," providing more representative input for subsequent models and improving prediction accuracy. Finally, by constructing a dynamic prediction model to generate refined prediction curves, it solves the problems of existing solutions' simple models, coarse prediction results, and inability to adapt to individual differences. Existing solutions use general time series models such as moving averages and ARIMA, which can only predict blood glucose levels for the next few hours. They cannot output refined information such as peak / trough times and fluctuation rate, and do not consider individual differences. This solution, however, constructs a dynamic model based on a multi-dimensional feature matrix and uses machine learning algorithms to learn a personalized mapping relationship between "feature combinations" and blood glucose fluctuations. This ultimately generates a prediction curve that includes peak / trough times and fluctuation rate. This model overcomes the limitations of traditional models' "shallow prediction dimensionality," providing more instructive and refined information. Furthermore, by learning individual feature adaptation differences, the predictions are more closely aligned with the patient's actual situation. Finally, bias analysis optimizes the model and generates personalized reports, addressing the problems of existing solutions lacking model iteration mechanisms and generalized warning and intervention recommendations.Existing methods fail to analyze biases after prediction, hindering continuous model optimization. Furthermore, they rely solely on fixed thresholds, neglecting individual patient differences (e.g., different risk thresholds for elderly and younger patients). This step compares predicted curves with actual data to calculate bias and trend consistency, pinpointing the source of model error. Subsequently, feature weights are optimized based on the bias results, enabling dynamic model iteration. This generates reports containing personalized risk warning thresholds (e.g., a warning for patient A if fasting blood glucose > 6.8 mmol / L) and intervention trigger conditions (e.g., increased light exercise if postprandial blood glucose peak exceeds 8.0 mmol / L). This process forms a closed loop of "prediction-validation-optimization-application," improving model accuracy through iteration and avoiding the limitations of generic recommendations through personalized reports, thereby enhancing the accuracy of blood glucose prediction. Attached Figure Description

[0065] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0066] Figure 1 This is a schematic diagram of the steps of the blood glucose fluctuation prediction method based on historical data of the present invention;

[0067] Figure 2 for Figure 1 A detailed flowchart of step S1. Detailed Implementation

[0068] The technical method of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0069] To achieve the above objectives, please refer to Figures 1 to 2 This invention provides a method for predicting blood glucose fluctuations based on historical data. In the embodiments of this invention, please refer to... Figure 1 The diagram shown illustrates the steps of the blood glucose fluctuation prediction method based on historical data according to the present invention. In this example, the blood glucose fluctuation prediction method based on historical data includes the following steps:

[0070] Step S1: Obtain the user's corresponding historical blood glucose monitoring data, daily behavior data, physiological status data and medical intervention data, and perform time axis alignment and outlier cleaning on various types of historical data to generate a standardized blood glucose-related dataset.

[0071] In this embodiment of the invention, a continuous glucose monitoring device acquires the user's glucose data for the past 90 days (5 minutes / time, 288 data points per day, unit mg / dL, including detection timestamp); a smart wearable device acquires daily behavior data (diet type categorized as staple food / vegetables / protein, food intake level 1-5, exercise type identified by acceleration as walking / running / cycling, exercise intensity categorized by heart rate as low 60-80 bpm / medium 81-120 bpm / high 121-160 bpm, sleep duration accurate to 10 minutes); a medical testing device acquires physiological status data (daily morning fasting weight in kg, accurate to 0.1; resting heart rate in bpm; cortisol level in nmol / L; insulin secretion in μU / mL); and an electronic medical record system acquires medical intervention data (type of hypoglycemic drug such as metformin / insulin, frequency of administration such as twice daily, insulin injection dose in IU, accurate to 0.5, adjustment timestamp accurate to minutes). All data timestamps were uniformly converted to UTC format (yyyy-MM-dd'T'HH:mm:ss'Z') and aligned to a 5-minute granularity along the timeline. An isolated forest algorithm (100 trees, 256 sample subsets) was used to identify outliers. Blood glucose levels exceeding 300 mg / dL or below 40 mg / dL were considered instrument errors. In behavioral data, a heart rate of 150 bpm despite low exercise intensity was deemed a logical contradiction. In physiological data, daily weight changes exceeding 2 kg were identified as abrupt changes. Outliers were directly removed. Time series interpolation was used for missing data. Linear interpolation was used for ≤3 consecutive missing time points, while for >3 time points, a weighted average of similar days (same week, similar activity levels) (weight 0.7) was used to complete the missing data. The final result was a standardized blood glucose-related dataset containing timestamps, blood glucose levels, behavioral characteristics, physiological indicators, and medical intervention fields.

[0072] Step S2: Extract the basic features and associated impact features corresponding to blood glucose fluctuations based on the standardized blood glucose-related dataset. The basic features include the mean blood glucose drift, intraday fluctuation range, and postprandial peak delay time. The associated impact features include the correlation coefficient between dietary glycemic index and blood glucose response, the dynamic relationship between exercise intensity and blood glucose reduction, and the matching degree between drug efficacy and blood glucose regulation. The basic features and associated impact features are fused in the spatiotemporal dimensions to construct a multidimensional feature matrix of blood glucose fluctuations.

[0073] In this embodiment of the invention, basic features are extracted based on a standardized dataset: When calculating the mean blood glucose drift, a sliding window of 60 minutes (12 data points) and a step size of 15 minutes (3 data points) are set. The mean of the window is calculated to generate a sequence. The difference between the mean of adjacent windows is divided by 15 minutes to obtain the rate of change. After exponential smoothing (smoothing coefficient 0.3), the result is normalized with the 7-day mean (e.g., 120 mg / dL) and the result is retained to two decimal places (e.g., +2.3%). The intraday fluctuation range is the difference between the maximum and minimum blood glucose values ​​each day (e.g., 40 mg / dL) divided by the time interval between occurrences (e.g., 6 hours) to obtain 6.7 mg / dL / h. The postprandial peak delay time is the interval (e.g., 90 minutes) between the time of eating (e.g., 7:00) and the time of the postprandial blood glucose peak (e.g., 8:30). Extracting correlation characteristics: the correlation coefficient between dietary glycemic index and blood glucose response, using 30 days of food data (glycemic index of rice 70, spinach 30), calculating the Pearson correlation coefficient (covariance divided by the product of the standard deviations of both, e.g., rice correlation coefficient 0.9); the dynamic relationship between exercise intensity and blood glucose reduction, for example, fitting with a nonlinear regression model y=5×ln(x)-10 (x is the mean exercise intensity, y is the blood glucose reduction), e.g., when x=100bpm, y=13mg / dL; the matching degree between drug action duration and blood glucose regulation, calculating the half-life according to the pharmacokinetic model (e.g., insulin 0.5h), predicting the theoretical regulatory effect with the correlation function, and obtaining the matching degree after normalizing the deviation from the actual value (e.g., 0.66). By fusing features through a spatiotemporal attention mechanism, the basic feature has a time decay factor of 1, and the related features have a diet / exercise decay factor of 0.8 and a drug decay factor of 0.9. Feature weights are assigned (mean drift of 0.3, diet coefficient of 0.2, and drug matching degree of 0.25) to generate a 3-row, 10-column multidimensional feature matrix of blood glucose fluctuations (rows correspond to the time dimension, and columns correspond to the feature dimension).

[0074] Step S3: Construct a dynamic prediction model based on the multidimensional feature matrix of blood glucose fluctuations, so as to learn the mapping relationship between different feature combinations and blood glucose fluctuation trends through the model, and generate a blood glucose fluctuation prediction curve for the user's future preset time period, which includes the time of occurrence of blood glucose peak and trough and the rate of change of fluctuation amplitude.

[0075] In this embodiment of the invention, a Transformer architecture dynamic prediction model is constructed based on a multi-dimensional feature matrix of blood glucose fluctuations. The input layer flattens a 3×10 matrix into a 30-dimensional vector, which is then converted into a 64-dimensional feature vector by the embedding layer. The multi-head self-attention layer has four attention heads (each with 16 dimensions) with a dropout probability of 0.1, calculating the feature dependencies at different time points. The feature interaction layer uses a gated linear unit (GLU), which generates 64-dimensional gated weights through sigmoid activation and multiplies them element-wise with the output of the attention layer to fuse features. The output layer is a time series prediction head (a 1-layer fully connected network with 64-dimensional input and 288-dimensional output), corresponding to the granular blood glucose values ​​at the 5-minute level for the next 24 hours. The model is trained using an adaptive learning rate algorithm (initial learning rate 0.001, cosine annealing period 10 epochs, minimum 0.00001), with the loss function being the mean square error between the predicted curve and the actual curve (sum of squared differences divided by 288), combined with an early stopping mechanism (the model stops if the loss does not decrease after 5 consecutive epochs of verification), for a total of 50 epochs of training. After training, input the user's feature matrix for the day to generate a blood glucose fluctuation prediction curve for the next 24 hours, marking the blood glucose peak (e.g., 140 mg / dL, occurring at 10:00), trough (e.g., 100 mg / dL, occurring at 16:00), and fluctuation amplitude change rate (e.g., a decrease of 20 mg / dL from 10:00 to 12:00, with a change rate of -10 mg / dL / h).

[0076] Step S4: Compare and analyze the blood glucose fluctuation prediction curve with the user's actual blood glucose monitoring data, calculate the prediction deviation and trend consistency, and generate corresponding deviation analysis results; optimize the feature weight allocation of the dynamic prediction model based on the deviation analysis results, and generate a personalized blood glucose fluctuation prediction report, which includes risk warning thresholds and intervention suggestion triggering conditions.

[0077] In this embodiment of the invention, the prediction curve (time series) is used... ) and the user's actual blood glucose data during the same period ( Time point alignment, calculate the absolute error E_abs(u) = |p_u - q_u| at each time point (e.g.) =120.5、 =119.8, E_abs(1)=0.7), relative error E_rel(u)=(E_abs(u) / q_u)×100% (e.g. 0.58%), generate error sequence. Calculate prediction deviation: mean absolute error MAE=total error / 288 (e.g. 320.5 / 288≈1.1mg / dL), root mean square error RMSE=√(sum of squared differences / 288) (e.g. √(450.2 / 288)≈1.2mg / dL), maximum error Max_E=3.5mg / dL; use dynamic time warping algorithm to calculate trend fit, construct 288×288 distance matrix, recursively calculate minimum cumulative distance (e.g. 320.5), theoretical maximum distance 37440 (130×288), fit S=1-(320.5 / 37440)≈0.9914. Preset deviation thresholds (MAE≤2.0, RMSE≤2.5, Max_E≤5.0) and a goodness-of-match threshold (S≥0.98). If a sample's MAE=2.2 or S=0.97, adjust the weights of the associated features (e.g., increase the dietary coefficient from 0.2 to 0.3) and retrain the model. Generate a new prediction curve based on the optimized model. Combine user physiological data (weight 65.0kg, resting heart rate 70bpm) and medical intervention data (metformin 500mg twice daily), set warning thresholds (fasting 70-100mg / dL, postprandial ≤140mg / dL), and trigger conditions (three consecutive times exceeding the upper limit suggests reducing staple food intake, and below the lower limit suggests supplementing carbohydrates). Integrate these into a personalized report, including a timeline, prediction curve, warning interval, and intervention suggestions.

[0078] Furthermore, as an embodiment of the present invention, reference is made to... Figure 2 As shown, Figure 1 A detailed flowchart of step S1 is shown below. In this embodiment, step S1 includes the following steps:

[0079] Step S11: Collect the user's historical blood glucose monitoring data through a continuous glucose monitoring device to obtain the blood glucose value and detection timestamp at each monitoring moment; collect daily behavior data through a smart wearable device, including diet type, food intake, exercise type, exercise intensity, and sleep duration; collect physiological status data through medical testing equipment, including daily weight, resting heart rate, cortisol level, and insulin secretion; obtain medical intervention data through an electronic medical record system, including the type of hypoglycemic drug, frequency of medication, insulin injection dosage, and adjustment time points;

[0080] In this embodiment of the invention, a continuous glucose monitoring device collects glucose data at 5-minute intervals via a subcutaneous sensor. Each collection generates a data packet containing a glucose value (unit: mg / dL, accurate to 0.1) and a detection timestamp (local time, format: yyyy-MM-ddHH:mm:ss). The device transmits the data packet to a data receiving terminal in real time via Bluetooth 4.2 protocol. The terminal stores the data packets in the order of collection, with a daily storage capacity of no less than 288 packets. Smart wearable devices collect daily behavioral data through built-in sensors: diet type is recorded by user-inputted text (e.g., "staple food - rice" or "vegetables - spinach"), and food intake is recorded according to preset levels (levels 1-5, with level 1 corresponding to less than 100g and level 5 corresponding to more than 500g); exercise type is identified by accelerometer (e.g., walking, running, cycling), and exercise intensity is divided by heart rate zones (low intensity 60-80 bpm, moderate intensity 81-120 bpm, high intensity 121-160 bpm); sleep duration is recorded by sleep monitoring module (continuous duration from falling asleep to waking up, accurate to 10 minutes), and the data is synchronized to the terminal every 30 minutes. In the medical testing equipment, the scale records daily fasting weight in kilograms (accurate to 0.1 kg), the heart rate monitor records resting heart rate in beats per minute (measured daily upon waking without activity), the cortisol detector generates nmol / L cortisol levels from blood samples (measured at a fixed time daily), and the insulin detector records insulin secretion (μU / mL, measured 1 hour after a meal). Data is imported to the terminal via USB. The electronic medical record system is accessed through the hospital intranet, extracting information such as the type of hypoglycemic drug (e.g., metformin, gliclazide), dosing frequency (e.g., twice daily, three times daily), insulin injection dose (unit IU, accurate to 0.5 IU), and adjustment time points (format yyyy-MM-ddHH:mm). The terminal obtains this data via encrypted transmission (TLS 1.3).

[0081] Step S12: Standardize the format of the collected historical data to convert timestamps to UTC time format, convert numerical data to a unified unit, and encode text data.

[0082] In this embodiment of the invention, a standardized processing flow is initiated for various types of historical data collected. Regarding timestamp processing, all local timestamps recorded by all devices (including time zone information) are converted to UTC time format. During conversion, the offset between the device's time zone and UTC is matched using a time zone database. For example, 2024-05-20 08:30:00 (UTC+8) is converted to 2024-05-20 00:30:00 (UTC+8). The converted timestamps are uniformly stored in the format "yyyy-MM-dd'T'HH:mm:ss'Z'". Numerical data units are standardized: Blood glucose values ​​in mmol / L (1 mmol / L ≈ 18 mg / dL) are converted to mg / dL using the conversion formula; weight values ​​in pounds (1 pound ≈ 0.4536 kg) are converted to kg and retained to one decimal place; insulin dose values ​​in U (1 U = 1 IU) are uniformly converted to IU; cortisol levels in μg / dL (1 μg / dL ≈ 27.59 nmol / L) are converted to nmol / L and retained to two decimal places. Text data encoding conversion: Text records such as diet type, exercise type, and medication type are first converted to byte arrays using UTF-8 encoding, and then converted to numerical codes using a preset encoding mapping table (e.g., "rice" corresponds to 101, "walking" corresponds to 201, and "metformin" corresponds to 301). The encoding mapping table is stored locally on the terminal and is periodically updated with the medical database to ensure encoding consistency. After processing, all data is stored in a structure of "timestamp-data type-feature value-unit / code" to avoid format confusion.

[0083] Step S13: Use the Isolation Forest algorithm to identify outliers in various types of historical data, including instrument error values ​​in blood glucose monitoring data, logically contradictory records in behavioral data, and jump values ​​in physiological data; use time series interpolation to complete missing data, and generate filler values ​​for missing time periods based on behavioral patterns and blood glucose change patterns of similar days;

[0084] In this embodiment of the invention, when using the isolated forest algorithm to identify outliers, the historical data is first divided into datasets according to data type (blood glucose dataset, behavioral dataset, and physiological dataset). For the blood glucose monitoring dataset, the number of trees in the isolated forest is set to 100, and the sample subset size is 256. The algorithm calculates the outlier score for each blood glucose value. Scores higher than 0.8 are judged as instrument error values ​​(e.g., a single blood glucose value suddenly exceeds 300 mg / dL and the data before and after are all within the normal range). For the behavioral dataset, the focus is on identifying logically contradictory records, such as "exercise type is running and exercise intensity is low intensity" and "food intake is level 5 and diet type is vegetables". The algorithm analyzes the correlation between features. Records with a correlation lower than a preset threshold (0.3) are judged as contradictory records. For the physiological dataset, the criteria for identifying jump values ​​are: a single-day weight change of more than 2 kg, a single-time resting heart rate change of more than 30 bpm, and a 24-hour cortisol level change of more than 50 nmol / L. The algorithm calculates the deviation of these values. Values ​​with a deviation of more than 3 times the standard deviation are judged as jump values. When handling missing data, time series interpolation is used. First, the time interval of the missing data is determined (e.g., a 5-minute interval for blood glucose data, a 30-minute interval for behavioral data). For data with no more than three consecutive missing time points, imputation values ​​are calculated using linear interpolation based on five valid data points before and after the missing time period (e.g., blood glucose value at missing time point t = (blood glucose value at time point after t - blood glucose value at time point before t) × (blood glucose value at time point before t) / (blood glucose value at time point after t - blood glucose value at time point before t) + blood glucose value at time point before t). For data with more than three consecutive missing time points, corresponding time period data for similar days (same week, similar weather, similar activity levels) are queried, and imputation values ​​are generated using a weighted average (weight coefficient of 0.7). Similar day matching is performed by calculating the similarity score of historical data; days with a score higher than 0.85 are considered similar days. Outliers are directly removed after identification. After missing data is imputed, data continuity is re-verified to ensure dataset integrity.

[0085] Step S14: Align and integrate the processed historical data according to the time axis to construct a standardized blood glucose-related dataset that includes time dimension, data type dimension, and feature index dimension. Each record contains multi-source data feature values ​​for the corresponding time point.

[0086] In this embodiment of the invention, when aligning and integrating various processed historical data along a timeline, a unified time granularity of 5 minutes is first determined (consistent with the blood glucose monitoring interval). A timeline is established based on the UTC timestamp, with each time node corresponding to a 5-minute time period (e.g., 2024-05-20T00:30:00Z corresponds to the time period 00:30:00-00:34:59). For each time node, data corresponding to the time period is extracted from each dataset: blood glucose data extracts the average blood glucose value within the time period (if multiple data points exist); behavioral data extracts the diet type code, food intake level, exercise type code, exercise intensity range, and sleep status (1 indicates sleep, 0 indicates wakefulness) within the time period; physiological data extracts the weight (only morning data is used daily, morning values ​​are used for other time periods), resting heart rate (only morning data is used daily), cortisol level, and insulin secretion within the time period; medical intervention data extracts whether medication or insulin injection was used within the time period (1 indicates presence, 0 indicates absence), and the corresponding drug code or injection dose. After integration, a standardized blood glucose-related dataset was constructed. Each record contains the following fields: "UTC timestamp - blood glucose value (mg / dL) - diet code - food intake level - exercise code - exercise intensity - sleep status - weight (kg) - resting heart rate (bpm) - cortisol (nmol / L) - insulin secretion (μU / mL) - medical intervention identifier - drug / dosage information". The field order is fixed and the data type is uniform (numerical / coded). The dataset is stored in ascending order by timestamp and supports fast querying by date range and data type, providing a structured data foundation for subsequent blood glucose fluctuation prediction.

[0087] Furthermore, step S2 includes the following steps:

[0088] Based on historical blood glucose monitoring data in a standardized blood glucose-related dataset, the mean and standard deviation of blood glucose within a preset period are calculated, and the mean blood glucose drift is generated by a mean sliding window to characterize the trend of blood glucose baseline changes. The difference between the maximum and minimum blood glucose values ​​within a day is calculated, and the intraday fluctuation amplitude parameter is generated by combining the time interval of occurrence. The time difference between the postprandial blood glucose peak and the time of meal is extracted to generate the postprandial peak delay time.

[0089] In this embodiment of the invention, the mean and standard deviation of blood glucose within a preset period (1 day) are calculated based on blood glucose monitoring data (5 minutes / time, 288 data points per day) from the past 7 days in a standardized blood glucose-related dataset. The daily mean is calculated by summing all data points for that day and dividing by 288. For example, if the total data for a certain day is 34560 mg / dL, the mean is 120 mg / dL. The standard deviation is obtained by taking the square root of the variance. The variance is calculated by summing the squares of the differences between each data point and the mean and dividing by 288. For example, if the variance is 64, the standard deviation is 8 mg / dL. The time sliding window length is set to 60 minutes (12 data points), and the sliding step size is set to 15 minutes (3 data points). The mean is calculated sequentially for each window, generating a window mean sequence. The mean values ​​of adjacent windows are differencing, and the rate of change of the mean is calculated by combining the window time interval (15 minutes). Then, the mean is filtered using exponential smoothing (smoothing coefficient 0.3), and finally normalized with the 7-day mean (120 mg / dL) to obtain the blood glucose mean drift (e.g., +2.5%). Calculate the difference between the daily maximum and minimum blood glucose levels. For example, if the maximum is 140 mg / dL and the minimum is 100 mg / dL, the difference is 40 mg / dL. Record the times of the maximum (10:00) and minimum (16:00) occurrences at 6-hour intervals. Use the ratio of the difference to the interval (40 mg / dL ÷ 6h ≈ 6.67 mg / dL / h) as the parameter for daily fluctuation range. Extract the time difference between the postprandial blood glucose peak and the time of meal. For example, if breakfast is eaten at 7:00 and blood glucose peaks at 8:30, the time difference is 90 minutes, which is used as the postprandial peak delay time.

[0090] Furthermore, the mean blood glucose drift, intraday fluctuation range, and postprandial peak delay time are used as basic features of blood glucose fluctuation to construct a basic feature vector;

[0091] In this embodiment of the invention, a basic feature vector is constructed by combining the mean blood glucose drift, intraday fluctuation range parameter, and postprandial peak delay time calculated in step S21 in a fixed order. The vector dimension is fixed at 3, and each feature value is standardized according to preset rules: the mean blood glucose drift is retained to 2 decimal places (e.g., +2.50%), the intraday fluctuation range parameter is retained to 1 decimal place (e.g., 6.7 mg / dL / h), and the postprandial peak delay time is converted to hourly units (e.g., 1.5h). For example, the basic feature vector of a sample is [+2.50%, 6.7 mg / dL / h, 1.5h]. Each element in the vector is bound to the calculation date and the corresponding blood glucose data time period to ensure that the feature value and the original data are traceable. The vector is stored in the feature database, and each vector corresponds to a unique user identifier and date identifier.

[0092] Furthermore, by combining daily behavioral data and blood glucose monitoring data, the correlation between the glycemic index of different foods and the increase in postprandial blood glucose was calculated using the Pearson correlation coefficient, generating a diet-blood glucose correlation coefficient; based on exercise intensity data and post-exercise blood glucose changes, a nonlinear regression model was used to fit the dynamic relationship curve between exercise intensity and blood glucose reduction; and based on medication time, dosage data, and blood glucose change curves, the matching degree parameter between drug concentration half-life and blood glucose regulation effect was calculated.

[0093] In this embodiment of the invention, the types of food (such as rice, noodles, and vegetables) and the corresponding postprandial 2-hour blood glucose increase (such as 20 mg / dL for rice, 15 mg / dL for noodles, and 5 mg / dL for vegetables) for the past 30 days are extracted from daily behavioral data. The Pearson correlation coefficient between the glycemic index of each food (preset 70 for rice, 60 for noodles, and 30 for vegetables) and the postprandial increase is calculated. The formula is the covariance divided by the product of the standard deviations of the two. For example, the covariance of the glycemic index of rice and the increase is 120, and the standard deviations are 15.5 and 8.7, respectively. The correlation coefficient is 120 ÷ (15.5 × 8.7) ≈ 0.9, which is used as the diet-blood glucose correlation coefficient. Exercise intensity data (low intensity 60-80 bpm, moderate intensity 81-120 bpm, high intensity 121-160 bpm) and blood glucose changes 1 hour after exercise (low intensity -5 mg / dL, moderate intensity -12 mg / dL, high intensity -20 mg / dL) were extracted and fitted using a nonlinear regression model (e.g., y = a × ln(x) + b, where y is the blood glucose decrease and x is the mean exercise intensity; this can also be calculated using a nonlinear correlation model in subsequent steps). A dynamic relationship curve was obtained by setting a = 5 and b = -10 (e.g., when x = 100 bpm, y = 5 × ln100 - 10 ≈ 13 mg / dL). Based on the medication time, dosage data, and blood glucose change curve, the matching degree parameter (e.g., 0.66) between the drug concentration half-life (e.g., 0.5 h for insulin) and the blood glucose regulation effect was calculated according to steps S2341-S2345. Each medication event corresponds to a unique matching degree parameter.

[0094] Furthermore, the diet-glucose correlation coefficient, exercise-glucose dynamic relationship curve, and drug-glucose matching degree parameter are used as correlation influence features to construct a correlation feature vector;

[0095] In this embodiment of the invention, a correlation feature vector is constructed by combining the diet-glucose correlation coefficient, the exercise-glucose dynamic relationship curve parameters, and the drug-glucose matching degree parameters. The vector dimension is fixed at N+3+1 (N is the number of food types, such as N=3 for 3 types of food): the first N digits are the diet-glucose correlation coefficient (e.g., [0.9, 0.7, 0.3]), the middle 3 digits are the exercise-glucose regression model parameters (a=5, b=-10, goodness of fit R²=0.85), and the last digit is the drug-glucose matching degree parameter (e.g., 0.66). For example, the correlation feature vector of a sample is [0.9, 0.7, 0.3, 5, -10, 0.85, 0.66]. Each element in the vector is labeled with the data source (e.g., diet data comes from 30 days of records, and exercise data comes from 20 exercise records) to ensure the reliability of the feature values. The vector and the basic feature vector are bound to the same user identifier and date identifier and stored together in the feature database.

[0096] Furthermore, the basic feature vector and the associated feature vector are fused through a spatiotemporal attention mechanism to generate a multidimensional feature matrix of blood glucose fluctuations that includes a time decay factor and feature importance weights.

[0097] In this embodiment of the invention, a spatiotemporal attention mechanism is used to fuse basic feature vectors and associated feature vectors. First, the two vectors are concatenated into a joint vector of length 10 (3+7). Time decay factors are set: the basic feature vector has a time decay factor of 1 (data from the current day), the associated feature vector has a decay factor of 0.8 for diet and exercise data (from the past 30 days), and a decay factor of 0.9 for medication data (from medication taken on the current day). Each element is multiplied by its corresponding decay factor. Feature importance weights are calculated: weights are assigned based on attention scores (based on the historical contribution of features to blood glucose fluctuations), such as a blood glucose mean drift weight of 0.3, a diet-blood glucose correlation coefficient weight of 0.2, and a medication matching parameter weight of 0.25. The remaining feature weights are distributed proportionally to ensure that all weights sum to 1. The decayed values ​​are multiplied by their weights to obtain weighted feature values. These are then arranged in the original vector order to generate a 3x10 multidimensional feature matrix of blood glucose fluctuations (rows correspond to the time dimension: current day, recent, and immediate; columns correspond to the feature dimension). Each element in the matrix is ​​labeled with a decay factor and weight value, which are used as feature input for subsequent blood glucose prediction models.

[0098] Furthermore, the calculation of the mean blood glucose drift using a mean sliding window includes:

[0099] Set the length and step size of the time sliding window, and determine the window parameters based on the time granularity of the standardized blood glucose-related dataset;

[0100] In this embodiment of the invention, based on a standardized blood glucose-related dataset with a time granularity of 5 minutes, the time sliding window length is set to 60 minutes, corresponding to 12 data time nodes (60 minutes ÷ 5 minutes / node); the sliding step size is set to 15 minutes, corresponding to 3 data time nodes (15 minutes ÷ 5 minutes / node). The window parameters are calibrated using the dataset timeline to ensure that the start time of each window is aligned with the timestamp of the data node (e.g., the first window starts at 2024-05-20T00:00:00Z, covering 12 nodes in the period from 00:00:00 to 00:59:59). The parameters are stored in the data processing configuration module and cannot be dynamically adjusted during subsequent calculations. If modifications are needed, the impact of the window length and step size on data coverage must be re-verified (ensuring that the overlap between adjacent windows is 45 minutes to avoid data omission).

[0101] Furthermore, historical blood glucose monitoring data are sequentially incorporated into a time-sliding window, and the average and median blood glucose values ​​within each time-sliding window are calculated to generate a window mean sequence.

[0102] In this embodiment of the invention, blood glucose values ​​are extracted from the standardized dataset in ascending order of timestamps. Starting from the first time node, the blood glucose values ​​of 12 consecutive nodes are sequentially included in a time sliding window. For the 12 values ​​in each window, the average blood glucose value is calculated by summing and dividing by 12 (keeping one decimal place; for example, if the total sum of the values ​​in the window is 1440 mg / dL, the average value is 120.0 mg / dL). The 12 values ​​are then sorted in ascending order using a sorting algorithm, and the average of the 6th and 7th values ​​is taken as the median (for example, after sorting, the values ​​are 100, 105, ..., 130, and the median is (118 + 122) / 2 = 120.0 mg / dL). After each window is calculated, the sliding window moves forward by 3 nodes according to the sliding step size, generating the next window and repeating the calculation, ultimately forming a sequence of window averages arranged in chronological order (e.g., the average value of the first window is 120.0, the average value of the second window is 122.5, etc.).

[0103] Furthermore, the window mean sequence of adjacent windows is differentially analyzed to obtain the mean change between each window, and the mean change rate is calculated in combination with the window time interval.

[0104] In this embodiment of the invention, by performing adjacent difference operations on the window mean sequence, the change in mean is obtained by subtracting the mean of the previous window from the mean of the next window (e.g., the change in mean is +2.5 mg / dL when the mean of the second window is 122.5 minus the mean of the first window is 120.0). The window time interval is fixed at 15 minutes (sliding step). The change in mean is divided by 15 minutes to obtain the rate of change in mean (e.g., +2.5 mg / dL ÷ 15 minutes ≈ +0.17 mg / dL / minute). During the calculation, the window time interval corresponding to each rate of change is recorded (e.g., a rate of +0.17 corresponds to the period 00:15:00-01:14:59) to ensure that the rate is accurately correlated with the time dimension and to avoid misalignment.

[0105] Furthermore, the rate of change of the mean is filtered by exponential smoothing to eliminate short-term fluctuations and retain long-term trend components.

[0106] In this embodiment of the invention, the mean rate of change is filtered using exponential smoothing, with a smoothing coefficient of 0.3 (a fixed value verified by historical data to balance the filtering effect and trend preservation). The filtering is calculated starting from the second rate of change, with the current smoothed value = 0.3 × current rate of change + (1 - 0.3) × previous smoothed value (e.g., if the current rate is +0.17, the previous smoothed value is the first rate +0.20, and the current smoothed value = 0.3 × 0.17 + 0.7 × 0.20 ≈ +0.19 mg / dL / min). After each smoothed value is generated, it is compared with the original rate of change. If the difference exceeds 0.05 mg / dL / min, the calculation process is re-verified to ensure that the filtering eliminates short-term fluctuations (e.g., a single rate jump of +0.5 mg / dL / min is smoothed to +0.25), while preserving long-term upward or downward trends.

[0107] Furthermore, the processed mean change rate is normalized to the baseline mean to generate the blood glucose mean drift, where a positive value indicates that the blood glucose baseline has moved upward and a negative value indicates that the blood glucose baseline has moved downward.

[0108] In this embodiment of the invention, the average value of the historical 7-day window mean sequence is taken as the baseline mean (e.g., if the sum of the 7-day mean is 10080 mg / dL, the baseline mean is 120.0 mg / dL). The filtered mean change rate is multiplied by the sliding step size of 15 minutes to obtain the cumulative change (e.g., rate + 0.19 × 15 ≈ +2.85 mg / dL). The cumulative change is then divided by the baseline mean to obtain the blood glucose mean drift (e.g., +2.85 ÷ 120.0 ≈ +2.4%). The drift is retained to two decimal places; a positive value indicates that the blood glucose baseline has moved upward (e.g., +2.4%), and a negative value indicates that the baseline has moved downward (e.g., -1.8%). The results are stored in window time order for subsequent blood glucose fluctuation trend analysis.

[0109] Furthermore, the calculation of the matching parameter between the drug concentration half-life and the blood glucose regulation effect based on medication time, dosage data, and blood glucose change curves includes:

[0110] Based on medication time and dosage data from medical intervention data, a pharmacokinetic model is constructed, and the absorption, distribution, metabolism and excretion of drugs in the body are simulated through this pharmacokinetic model. At the same time, the predicted drug concentration values ​​at different time points are calculated, and drug concentration-time curves are generated.

[0111] In this embodiment of the invention, a two-compartment pharmacokinetic model is constructed based on the medication time (UTC time accurate to the minute, such as 2024-07-01T08:00:00Z) and dosage data (such as insulin 10 IU / dose, metformin 850 mg / dose) recorded in medical intervention data. The model includes four core modules: the absorption module sets parameters according to the route of administration, and the absorption rate constant of subcutaneously injected insulin is fixed at... The absorption rate constant of oral metformin is fixed at 1. The distribution module divides the insulin distribution into a central compartment (blood) and a peripheral compartment (muscle and adipose tissue). The central compartment distribution volume is 0.2 L / kg for insulin and 0.08 L / kg for metformin, while the central compartment distribution volume is 0.7 L / kg and the peripheral compartment distribution volume is 0.3 L / kg. The metabolic module is related to the liver's metabolic capacity and the insulin elimination rate constant. Metformin elimination rate constant The excretion module incorporates renal function, showing that 15% of insulin and 85% of metformin are excreted through the kidneys. After inputting the administration time and dosage, the model calculates the drug concentration in the central compartment at 15-minute time steps, generating a drug concentration-time curve. The horizontal axis represents the time after administration (in hours), and the vertical axis represents the drug concentration (insulin in μU / mL, metformin in mg / L). For example, insulin concentration reaches 70 μU / mL at 0.5 hours, decreases to 35 μU / mL at 1 hour, and decreases to 17.5 μU / mL at 2 hours. The curve data is stored in a structured table in chronological order to ensure a unique concentration value for each time point.

[0112] Furthermore, the drug concentration half-life parameter is extracted from the drug concentration-time curve, specifically the time required for the drug concentration to drop to half of its initial value, and the effective action period of the drug is determined in combination with the pharmacokinetic characteristics.

[0113] In this embodiment of the invention, the time and concentration value corresponding to the peak drug concentration are extracted from the drug concentration-time curve. For example, insulin reaches its peak concentration of 70 μU / mL 0.5 hours after administration. Using the peak concentration as the initial value, the time point corresponding to the concentration decreasing to half of the initial value (35 μU / mL) is found along the curve (1 hour after administration). The difference between the two time points (0.5 hours) is the drug concentration half-life. The effective period of action is determined by combining the pharmacokinetic characteristics: starting from the administration time, the effective period of action is defined as the time point from the drug concentration decreasing to 10% of the peak concentration (7 μU / mL) (the concentration of insulin decreases to 7 μU / mL 3 hours after administration). For metformin, the peak concentration (10 mg / L) is reached 2.5 hours after administration, the concentration decreases to 5 mg / L at 5.5 hours (half-life of 3 hours), and the concentration decreases to 1 mg / L at 14 hours (10% of the peak concentration). The effective period of action is 0-14 hours. The half-life and effective duration of each medication event are bound and stored together, and associated with the corresponding drug type and dosage to ensure the uniqueness of the parameters.

[0114] Furthermore, the medication time is aligned with the blood glucose change curve on the time axis, and the blood glucose change characteristics within the preset time period after medication are extracted, including the blood glucose peak decrease, the rate of change of blood glucose curve slope, and the time for blood glucose to return to the baseline level.

[0115] In this embodiment of the invention, by aligning the medication time (2024-07-01T08:00:00Z) with the time axis of the blood glucose change curve, and using the medication time as a benchmark, blood glucose data within the effective action period (0-3 hours) after medication is extracted. The reduction in blood glucose peak is calculated: the blood glucose peak after medication (160 mg / dL 1 hour after medication) and the average blood glucose level 30 minutes before medication (130 mg / dL) are compared. The difference is divided by the average value before medication to obtain the reduction ((160-130) / 130≈23.1%). The rate of change in the blood glucose curve slope is calculated: the post-medication period is divided into 1-hour segments, and the linear slope of the blood glucose data for each segment is calculated (0-1 hour slope +30 mg / dL / h, 1-2 hour slope -25 mg / dL / h, 2-3 hour slope -10 mg / dL / h). The rate of change is calculated by dividing the difference between the slopes of the two segments by the time interval (1 hour). For example, the rate of change for 1-2 hours is (-25-30) / 1 = -55 mg / dL / h², and the rate of change for 2-3 hours is (-10+25) / 1 = 15 mg / dL / h². The time it takes for blood glucose to return to the baseline level is calculated: the baseline level is the average blood glucose level at the same time point in the 7 days prior to medication (128 mg / dL). The time when blood glucose first drops to this value after medication (2.5 hours after medication) is the regression time. All blood glucose change characteristics are linked to medication records to ensure data traceability.

[0116] Furthermore, a correlation function between drug concentration and blood glucose regulation effect was constructed, with drug concentration half-life as the input variable and blood glucose peak reduction, blood glucose curve slope change rate and blood glucose regression time as the output variables. The parameters of the correlation function were obtained through nonlinear fitting.

[0117] In this embodiment of the invention, a correlation function between drug concentration and blood glucose regulation effect is constructed, with the drug concentration half-life as the input variable. (per hour), the output variable is the drop in peak blood glucose level. (Percentage), Rate of change in the slope of the blood glucose curve (mg / dL / h²), blood glucose return time (hours). The functional form adopts the same multi-output nonlinear model as before: ; ; 25 historical insulin use records were selected ( Range 0.4-0.6 hours, Range 20%-25%, Range -60 to -50 mg / dL / h² (range 2-3 hours), using a multi-objective particle swarm optimization algorithm to fit the parameters. The particle number was set to 40, the number of iterations to 150, and the objective function weights were... =0.4、 =0.3、 =0.3, and finally the parameter is obtained, for example: =28、 =1.1、 =2.5、 =-6.8; =-55、 =0.6、 =-0.3、 =-4.2; =2.2、 =0.15、 =-0.08、 =1.1, determine the specific expression of the correlation function.

[0118] Furthermore, the deviation between the theoretical blood glucose regulation effect corresponding to the drug concentration half-life and the actual blood glucose change characteristics is calculated, and the matching degree parameter between the drug concentration half-life and the blood glucose regulation effect is generated by deviation normalization. The matching degree parameter ranges from 0 to 1.

[0119] In this embodiment of the invention, by selecting the drug concentration half-life t_(1 / 2) = 0.5 hours for a certain insulin dosing event, and substituting it into the correlation function, the theoretical blood glucose regulation effect is calculated: ; ≈ ≈-21.15-0.075-4.2≈-25.425mg / dL / h²; ≈ ≈2.244 hours. Obtain the actual blood glucose change characteristics of this event: =23.1%, =-24.8mg / dL / h² =2.5 hours. Calculate the deviation value: Deviation = |23.1% - 22.5%| = 0.6%; Deviation = |-24.8-(-25.425)| = 0.625 mg / dL / h²; Deviation = |2.5 - 2.244| = 0.256 hours. Normalize the deviation value: The maximum historical deviation is 2%, and the normalized deviation is 0.6% / 2% = 0.3. The maximum historical deviation was 3 mg / dL / h², and the normalized deviation was approximately 0.625 / 3 ≈ 0.208. The maximum historical deviation is 0.5 hours, and the normalized deviation is approximately 0.256 / 0.5. The matching degree parameter is calculated as: 1 - (0.3 + 0.208 + 0.512) / 3 = 1 - 0.34 ≈ 0.66, with a value range of 0-1. A value of 0.66 indicates a good match between the drug concentration half-life and the blood glucose regulation effect of this medication. The matching degree parameter is stored in the medication record for subsequent optimization of the blood glucose prediction model.

[0120] Furthermore, the constructed correlation function between drug concentration and blood glucose regulation effect uses the drug concentration half-life as the input variable and the blood glucose peak reduction, the rate of change of the blood glucose curve slope, and the blood glucose regression time as output variables. The parameters of the correlation function are obtained through nonlinear fitting, including:

[0121] Define the input and output variables for the correlation function. Let the input variable be the drug concentration half-life. The output variables include the peak blood glucose decrease. , rate of change of blood glucose curve slope and blood glucose return time And construct the corresponding multi-output nonlinear correlation function model. ;in, , , These are the principal coefficients of the correlation function. , , The decay / growth coefficient, , , For adjustment coefficients, , , This is the reference offset;

[0122] In this embodiment, the input variable for the correlation function is defined as the drug concentration half-life. The unit is fixed in hours, and the value range is limited to 1-12 hours (covering the half-life range of common hypoglycemic drugs); the output variable is the decrease in blood glucose peak value. These are percentage values, ranging from -20% to 30% (negative values ​​indicate elevated blood sugar, and positive values ​​indicate decreased blood sugar). The percentage change in the slope of the blood sugar curve is also considered. The unit is mg / dL / h², with a range of -10 to 10, and the blood glucose regression time is... The unit is hours, and the value range is 1-24 hours. Construct a multi-output nonlinear correlation function model: ;in, , , These are the principal coefficients of the correlation function. , , The decay / growth coefficient, , , For adjustment coefficients, , , As the reference offset, In the function, the exp term describes the decay characteristics of the rate of decrease when the half-life is extremely short, the ln term captures the linear effect of half-life changes on the rate of decrease, and the principal coefficients... Value range 0-50, attenuation coefficient The value range is 0.1-2, and the adjustment coefficient is... Value range: -5 to 5, reference offset The value range is -10 to 10; In the function, the fractional terms describe the saturation effect of the half-life on the slope, the quadratic terms capture nonlinear changes, and the principal coefficients... Value range: -20 to 20, attenuation coefficient The value range is 0.05-1, and the adjustment coefficient is... Value range: -0.5 to 0.5, reference offset The value range is -5 to 5; The linear term in the function reflects the basic effect of half-life on regression time, the exp term describes the time extension effect for long half-lives, and the principal coefficients... The value ranges from 0.5 to 5, and the growth coefficient is... The value range is 0.01-0.5, and the adjustment coefficient is... Value range: -0.2 to 0.2, reference offset The value range is 0-10, and the specific values ​​of all parameters are determined through subsequent optimization.

[0123] Furthermore, a training dataset was constructed based on the obtained drug concentration half-life, peak blood glucose decrease, rate of change of blood glucose curve slope, and blood glucose regression time, where each sample contains a set of data. Corresponding value, where Extracted from drug concentration-time curves. Results from the analysis of blood glucose change curves after medication;

[0124] In this embodiment of the invention, a training dataset is constructed by extracting 30 sets of medication records for the same hypoglycemic drug (such as metformin) from historical medical data. Each set of samples contains... Quadruple. Extracted from drug concentration-time curves, such as in sample group 1. =4.2 hours, Group 2 =3.8 hours; Calculated by comparing the peak blood glucose level after medication with the average blood glucose level 30 minutes before medication, such as in Group 1. =(138-122) / 122≈13.1%, Group 2 =(145-118) / 118≈22.9%; The slope was calculated based on the segmented slopes 2 hours after medication administration. For example, in Group 1, the slope from 0 to 2 hours was +4.5 mg / dL / h, and the slope from 2 to 4 hours was -2.8 mg / dL / h. =(-2.8-4.5) / 2≈-3.65mg / dL / h², Group 2 =(-3.2-5.1) / 2≈-4.15mg / dL / h²; The time it takes for blood glucose to return to the mean value of the 7 days prior to medication, such as in Group 1. =7.5 hours for group 1, 6.8 hours for group 2. All sample data are calculated as follows: Sort in ascending order and remove. Exceeding -20% to 30%, Exceeding -10 to 10 Of the abnormal samples that were more than 1 to 24 hours old, 28 sets of valid samples were ultimately retained for training.

[0125] Furthermore, a multi-objective particle swarm optimization algorithm is used to nonlinearly fit the correlation function parameters, with the objective function being the minimization of the weighted mean square error between the predicted and actual sample values. The specific expression for the objective function is as follows:

[0126] ;

[0127] in, For the sample size, , , The predicted value is the correlation function. , , For the actual sample value, , , Let be the error weights for each output variable, and ;

[0128] In this embodiment of the invention, a multi-objective particle swarm optimization algorithm is used for parameter fitting, with the number of particles set to 50, and each particle corresponding to 12 parameters ( to A set of values ​​for ). The weights in the objective function Loss are set to =0.4 ( Error weights) =0.3 ( Error weights) =0.3 ( Error weights), satisfying Calculate the predicted value corresponding to each group of particle parameters: [This involves] taking the sample... Substituting the three correlation functions, we get , , Then calculate the mean square error of each output variable (e.g., Mean square error = 1 / 28 The loss value is obtained by weighted summation. During the algorithm iteration, particles update their positions by tracking their individual optimal solutions and the global optimal solution. The initial value of the inertia weight in the velocity update formula is 0.9, which decreases linearly to 0.4 with the number of iterations. The learning factors c1=c2=2 to ensure algorithm convergence. The global optimal loss value is recorded after each iteration to determine the iteration progress.

[0129] Furthermore, an iteration termination condition is set: when the objective function value is less than a preset error threshold or the number of iterations reaches a maximum threshold, parameter optimization stops, and the optimal parameter combination is output. ;

[0130] In this embodiment of the invention, the iteration termination condition is set to a dual-threshold control: a preset error threshold of 0.02 (the fitting accuracy is considered satisfactory when the loss value is less than 0.02), and a maximum number of iterations of 200 (to avoid over-iteration). After the algorithm starts, the global optimal loss value gradually decreases from the initial 0.8 to 0.05 in the first 50 iterations. At the 120th iteration, the loss value drops to 0.018, satisfying the error threshold of less than 0.02, thus triggering the termination condition. After stopping parameter optimization, the 12 parameter values ​​corresponding to the globally optimal particle at this point are extracted: =32.5、 =0.8、 =2.3、 =-5.1; =-18.2、 =0.5、 =-0.3、 =2.1; =2.8、 =0.2、 =-0.1、 =1.5, forming the optimal parameter combination.

[0131] Furthermore, by substituting the optimal parameter combination into a multi-output nonlinear correlation function model, the correlation function between drug concentration and blood glucose regulation effect is constructed. This function can be used to determine the correlation between any drug concentration and its half-life. The corresponding blood glucose peak decrease, blood glucose curve slope change rate, and blood glucose regression time prediction value can be directly calculated.

[0132] In this embodiment of the invention, the specific function is obtained by substituting the optimal parameter combination into the multi-output nonlinear correlation function model: =32.5×exp(-0.8×1 / )+2.3×ln( -5.1; =-18.2× / (1+0.5× -0.3× ²+2.1; =2.8× +0.2×exp(-0.1× +1.5. Verify function validity: Select a new drug use event. =4.0 hours, substituting into the function yields... ≈14.2% ≈-3.5mg / dL / h² ≈7.2 hours, compared to the actual value of the event ( =13.8%, =-3.7mg / dL / h² The error for half-life (e.g., 7.0 hours) is less than 5%, meeting the accuracy requirements. This function can be directly used to input any drug concentration and half-life. Within 1-12 hours, the system quickly calculates the corresponding three predicted values ​​of blood glucose regulation effect, providing core model support for blood glucose fluctuation prediction.

[0133] Furthermore, step S3 includes the following steps:

[0134] The multidimensional feature matrix of blood glucose fluctuation is divided into a training sample set and a validation sample set in chronological order. The training sample set contains historical feature data and corresponding subsequent blood glucose fluctuation results, while the validation sample set is used for model performance evaluation.

[0135] In this embodiment of the invention, the multidimensional feature matrix of blood glucose fluctuations is divided chronologically, selecting feature matrix data from the past 90 days (one 3x10 matrix per day). The data from the first 70 days is used as the training sample set, and the data from the last 20 days is used as the validation sample set. Each feature matrix in the training sample set is associated with the actual blood glucose fluctuation results of the following 24 hours (recorded at a 5-minute granularity, totaling 288 blood glucose values). For example, the feature matrix of day 1 corresponds to the actual blood glucose data from 0:00 to 24:00 on day 2, ensuring that the features and results are aligned in time. The training sample set is divided into batches, with each batch containing feature matrices and corresponding blood glucose results for 32 consecutive days. Data within a batch is normalized to zero mean (mean minus the overall mean of the sample set, then divided by the standard deviation). The validation sample set does not participate in the normalization parameter calculation; it is directly normalized using the mean and standard deviation of the training sample set. Each validation sample is also associated with the actual blood glucose data of the following 24 hours for subsequent model performance evaluation. The sample set is stored by date index to ensure that the chronological order is not disordered.

[0136] Furthermore, a dynamic prediction model based on the Transformer architecture is constructed. This dynamic prediction model includes an input layer, a multi-head self-attention layer, a feature interaction layer, and an output layer. The input layer receives a multi-dimensional feature matrix of blood glucose fluctuations, the multi-head self-attention layer captures the dependencies between features at different time points, the feature interaction layer fuses basic features and related influence features through a gating mechanism, and the output layer generates blood glucose fluctuation curves for future periods through a time series prediction head.

[0137] In this embodiment of the invention, a dynamic prediction model based on the Transformer architecture is constructed. The input layer receives a 3x10 multidimensional feature matrix of blood glucose fluctuations. After flattening the matrix into a 30-dimensional vector, it is converted into a 64-dimensional feature vector through an embedding layer, with the embedding dimension fixed at 64. The multi-head self-attention layer sets up four attention heads, each with a dimension of 16. It calculates the dependency relationship of features at different time points by scaling dot product attention. The attention weight matrix has a dimension of 64×64, and the dropout probability is set to 0.1 to prevent overfitting in the attention calculation. The feature interaction layer uses a gated linear unit (GLU) as the gating mechanism. It takes the 64-dimensional vector output from the multi-head self-attention layer as input, generates gating weights (64-dimensional) through a sigmoid activation function, and multiplies them element-wise with the original vector to achieve dynamic fusion of basic features and related influencing features. The output is still a 64-dimensional vector. The output layer is a time series prediction head, which uses a 1-layer fully connected network (64-dimensional input, 288-dimensional output) to predict blood glucose values ​​at a granular level of 5 minutes for the next 24 hours. The activation function uses linear activation to ensure that the predicted values ​​conform to the blood glucose value range (70-200 mg / dL).

[0138] Furthermore, an adaptive learning rate optimization algorithm is used to train the dynamic prediction model in order to adjust the model parameters by minimizing the mean square error between the predicted curve and the actual blood glucose curve, and an early stopping mechanism is combined to prevent the model from overfitting.

[0139] In this embodiment of the invention, an adaptive learning rate optimization algorithm is used to train the model. The initial learning rate is set to 0.001, the learning rate adjustment strategy is cosine annealing, and the period is set to 10 epochs. After each epoch, the learning rate decays according to a cosine curve, with a minimum learning rate of 0.00001. The loss function is the mean square error between the predicted curve and the actual blood glucose curve, calculated as the sum of the squares of the differences between the predicted and actual values ​​at each time point, divided by 288 (the number of time points). The training process is batch-iterative, with a total of 50 epochs. Each epoch contains two batches of the training sample set (70 days ÷ 32 ≈ 2.19, rounded down to 2). The early stopping mechanism is set to stop training if the validation set loss function value does not decrease for 5 consecutive epochs. The validation set loss is calculated in the same way as the training set loss, and the model parameters at the time of stopping are saved as the optimal model parameters to avoid overfitting the model on the training set. During training, the training set and validation set loss values ​​are output every 2 epochs to monitor the training progress.

[0140] Furthermore, the validation sample set will be input into the trained dynamic prediction model to generate a blood glucose fluctuation prediction curve for a future preset time period. This blood glucose fluctuation prediction curve includes the predicted blood glucose value, prediction confidence interval, and feature contribution index at each time point.

[0141] In this embodiment of the invention, the 20 feature matrices of the validation sample set (normalized by the training set parameters) are input one by one into the trained dynamic prediction model. The model outputs a blood glucose fluctuation prediction curve for the next 24 hours (288 time points). The predicted blood glucose value at each time point is retained to one decimal place (e.g., 120.5 mg / dL), and the prediction confidence interval is calculated: the mean ± 1.96 times the standard deviation of the probability distribution of the model output layer (assuming a normal distribution) is taken as the 95% confidence interval (e.g., 120.5 ± 5.2 mg / dL). The feature contribution index is calculated using SHAP values. Each feature (30 dimensions) corresponds to the contribution at each time point. A positive value indicates that the feature increases the predicted value, and a negative value indicates that it decreases it. The larger the absolute value of the contribution, the stronger the influence (e.g., the contribution of the blood glucose mean drift to the predicted value at 10:00 is +3.2, and the contribution of the diet-blood glucose correlation coefficient is -1.8). The prediction curve uses time as the horizontal axis (0:00-24:00, 5-minute intervals) and blood glucose values ​​(70-200 mg / dL) as the vertical axis, marking the predicted value, confidence interval, and top 3 contribution features at each time point to visually demonstrate the prediction results and influencing factors.

[0142] Furthermore, step S4 includes the following steps:

[0143] Align the blood glucose fluctuation prediction curve with the user's actual blood glucose monitoring data during the same period, calculate the absolute error and relative error between the predicted value and the actual value at each corresponding time point, and generate an error sequence.

[0144] In this embodiment of the invention, the 24-hour blood glucose fluctuation prediction curve (time series P=[p1,p2,...) output by the dynamic prediction model is used to... [p288], 5-minute granularity, 288 time points) and the user's actual blood glucose monitoring data during the same period (time series Q=[q1,q2, p288], 5-minute granularity, 288 time points) and time series data (time series Q=[q1,q2, p288]). Align the time points to ensure that p_u and q_u correspond to the same time (e.g., p1 corresponds to 0:00, and q1 also corresponds to 0:00). Calculate the absolute error E_abs(u) = |p_u - q_u| (retain 1 decimal place). For example, if p1 = 120.5 mg / dL and q1 = 119.8 mg / dL, E_abs(1) = 0.7 mg / dL; if p2 = 121.2 mg / dL and q2 = 120.5 mg / dL, E_abs(2) = 0.7 mg / dL. Calculate the relative error E_rel(u) = (E_abs(u) / q_u) × 100% (rounded to two decimal places), such as E_rel(1) = (0.7 / 119.8) × 100% ≈ 0.58%, E_rel(2) = (0.7 / 120.5) × 100% ≈ 0.58%. Arrange the E_abs(u) and E_rel(u) of the 288 time points in order to generate the error sequence E_abs = [0.7, 0.7, ... ]、E_rel=[0.58%,0.58%, The error sequence is bound to the time sequence for storage, and the specific time corresponding to each error is marked.

[0145] Furthermore, the prediction deviation is calculated based on the error sequence, including the mean absolute error, root mean square error, and maximum error value, and the trend fit between the predicted curve and the actual curve is calculated through the dynamic time warping algorithm.

[0146] In this embodiment of the invention, the prediction deviation is calculated based on the error sequence: the mean absolute error MAE = (∑E_abs(u) from u=1 to 288) / 288, such as when the sum of E_abs is 320.5mg / dL, MAE = 320.5÷288≈1.1mg / dL; the root mean square error RMSE = √[(∑(p_u-q_u)² from u=1 to 288) / 288], such as when the sum of (p_u-q_u)² is 450.2, RMSE = √(450.2÷288)≈1.2mg / dL; the maximum error value Max_E = max(E_abs(u)), such as when the maximum value in the E_abs sequence is 3.5mg / dL, Max_E = 3.5mg / dL. Trend consistency was calculated using a dynamic time warping algorithm: a 288×288 distance matrix D (elements being Euclidean distances) was constructed, the cumulative distance matrix was initialized, and trend constraint factors (α=0.3, ε=0.001) were introduced. The minimum cumulative distance was recursively calculated, and the optimal path was traced backwards. The final optimal path total distance was 320.5, and the theoretical maximum distance was 37440 (130mg / dL×288). The trend consistency S = 1 - (320.5 / 37440) ≈ 0.9914 (rounded to 4 decimal places). The MAE, RMSE, Max_E, and S values ​​were integrated into a deviation-consistency assessment report, clarifying the calculation basis and numerical range of each indicator.

[0147] Furthermore, a deviation threshold and a consistency threshold are set. When the prediction deviation exceeds the deviation threshold or the trend consistency is lower than the consistency threshold, the model optimization mechanism is triggered to adjust the weight allocation of the related influence features in the dynamic prediction model.

[0148] In this embodiment of the invention, preset prediction deviation thresholds and trend consistency thresholds are used: MAE threshold is set to 2.0 mg / dL, RMSE threshold is set to 2.5 mg / dL, Max_E threshold is set to 5.0 mg / dL, and trend consistency threshold is set to 0.98. Comparing the current evaluation results with the thresholds: MAE = 1.1 mg / dL (less than 2.0), RMSE = 1.2 mg / dL (less than 2.5), Max_E = 3.5 mg / dL (less than 5.0), and S = 0.9914 (greater than 0.98), all meet the threshold requirements, and model optimization is not triggered. If a sample has an MAE of 2.2 mg / dL (above 2.0) or an S of 0.97 (below 0.98), the model optimization mechanism is triggered: the weights of the associated features in the dynamic prediction model are adjusted. For example, the original weight of the diet-blood glucose correlation coefficient is 0.2. If the evaluation finds that the diet feature has a large contribution to the error, the weight is increased to 0.3. The original weight of the drug-blood glucose matching parameter is 0.25. If the drug feature prediction is accurate, the weight remains unchanged. After adjustment, the model is retrained. The training data includes the error sequence and feature matrix of the sample. The number of iterations is set to 10 to ensure that the weight adjustment is effective.

[0149] Furthermore, based on the optimized dynamic prediction model, a blood glucose fluctuation prediction curve is regenerated. Combined with the user's physiological state data and medical intervention data, the risk warning threshold for abnormal blood glucose fluctuations is determined, and a personalized blood glucose fluctuation prediction report containing the risk warning threshold and intervention suggestion trigger conditions is generated.

[0150] In this embodiment of the invention, a 24-hour blood glucose fluctuation prediction curve for the user is regenerated based on an optimized dynamic prediction model. The curve is labeled with the predicted value and 95% confidence interval (e.g., 120.5 ± 1.2 mg / dL) at each time point. Combining the user's physiological status data (fasting weight in the morning of the past 7 days: 65.0 kg; resting heart rate: 70 bpm; cortisol level: 25 nmol / L) and medical intervention data (metformin 500 mg twice daily; insulin 8 IU pre-meal injection), the warning thresholds for abnormal blood glucose fluctuation risk are determined: the upper limit for fasting blood glucose warning is 100 mg / dL, the lower limit is 70 mg / dL, and the upper limit for postprandial 2-hour blood glucose warning is 140 mg / dL. Intervention suggestion triggering conditions are set: when the predicted value exceeds the warning upper limit for 3 consecutive time points, the suggestion to "reduce staple food intake" is triggered; when the predicted value is below the warning lower limit for 3 consecutive time points, the suggestion to "appropriately supplement carbohydrates" is triggered; when the predicted value is close to the drug's action period and the fluctuation range exceeds 5 mg / dL, the suggestion to "confirm medication dosage" is triggered. By integrating prediction curves, warning thresholds, triggering conditions, and intervention suggestions, a personalized blood glucose fluctuation prediction report is generated. The report includes a timeline, prediction value curves, warning interval markings, and corresponding intervention suggestions for the time period, making it convenient for users and medical staff to refer to.

[0151] Furthermore, the calculation of the trend fit between the predicted curve and the actual curve using the dynamic time warping algorithm includes:

[0152] Representing the blood glucose fluctuation prediction curve as a time series The actual blood glucose monitoring curve is represented as a time series. ,in and These represent the number of time points for the predicted curve and the actual curve, respectively.

[0153] In this embodiment of the invention, a 24-hour blood glucose fluctuation prediction curve is extracted from the output of a dynamic prediction model, divided into 288 time points at a 5-minute time granularity, and represented as a time series. ,in ( =1 to 288) is the first Predicted blood glucose values ​​at each time point (rounded to one decimal place), such as =120.5mg / dL (corresponding to 0:00) =121.2 mg / dL (corresponding to 0:05) , =119.8 mg / dL (corresponding to 23:55). The actual 24-hour blood glucose monitoring curve was extracted from the standardized glucose-related dataset, also divided into 5-minute granularities, resulting in 288 time points, represented as a time series. ,in ( =1 to 288) is the first The actual blood glucose values ​​at each time point (rounded to one decimal place), such as =119.8mg / dL =120.5mg / dL , =120.2 mg / dL. Ensure that the time points P and Q correspond one-to-one, i.e. and Corresponding to the same time ( =v (when) and All are fixed at 288 to avoid time misalignment affecting subsequent calculations.

[0154] Furthermore, construct × Distance matrix , where matrix elements Indicates the predicted sequence number The point and the actual sequence Euclidean distance between points;

[0155] In this embodiment of the invention, a 288×288 distance matrix is ​​constructed. Matrix elements Indicates the predicted sequence number Points With the v-th point of the actual sequence The Euclidean distance is calculated as follows: = (Because it's single-dimensional data, the Euclidean distance is the absolute value.) For example... =√[(120.5-119.8)²]=0.7, =√[(120.5-120.5)²]=0.0, =√[(121.2-119.8)²]=1.4....

[0156] Furthermore, a dynamic programming algorithm is used to find the source from... arrive The optimal path is the one with the minimum sum of distances along the path, where the path constraints satisfy the conditions of monotonicity and continuity.

[0157] In this embodiment of the invention, a dynamic programming algorithm is used to find the source from arrive The optimal path, the path constraint satisfies monotonicity (only allowed from... Towards or Movement (no reversal or jumping allowed) and continuity (path covers all time points without breaks). The algorithm initializes the dynamic programming matrix DP. The first line First column ,the remaining By traversing and calculating, we obtain DP(288,288), which is the total distance of the optimal path.

[0158] Furthermore, the ratio of the total distance of the optimal path to the theoretical maximum distance is calculated and converted into a trend fit S = 1 - (total distance of the optimal path / theoretical maximum distance);

[0159] In this embodiment of the invention, the total distance of the optimal path is calculated, for example, by using a dynamic programming algorithm, DP(288,288)=320.5 (the sum of Euclidean distances). The theoretical maximum distance is the sum of the maximum possible differences between the predicted and actual values. The blood glucose range is fixed at 70-200 mg / dL, and the maximum Euclidean distance at a single time point is 200-70=130. The theoretical maximum distance over 288 time points = 130×288=37440. The ratio of the total distance of the optimal path to the theoretical maximum distance is converted into a trend fit S=1-(320.5 / 37440)=1-0.00856≈0.9914, rounded to four decimal places. If the total distance of the optimal path for a certain sample is 1872, and the theoretical maximum distance is still 37440, then S = 1 - (1872 / 37440) = 1 - 0.05 = 0.95, ensuring that the value of S is between 0 and 1. The closer the value is to 1, the higher the trend consistency.

[0160] Furthermore, the trend consistency is evaluated in segments. When S is greater than or equal to the preset high consistency threshold, the predicted trend is determined to be highly reliable; when S is between the high and low consistency thresholds, the predicted trend is determined to be basically reliable; when S is less than the preset low consistency threshold, the predicted trend is determined to need to be corrected.

[0161] In this embodiment of the invention, a high-consistency threshold of 0.98 and a low-consistency threshold of 0.90 are preset for trend consistency, and the segmented evaluation rules are fixed. When S ≥ 0.98, such as S = 0.9914, the predicted trend is considered highly reliable, indicating that the overall trend, peak and trough occurrence times, and numerical deviations between the predicted curve and the actual curve are minimal, and it can be directly used for blood glucose fluctuation early warning. When 0.90 ≤ S < 0.98, such as S = 0.95, the predicted trend is considered basically reliable, the overall trend of the predicted curve is consistent with the actual trend, but the numerical deviations are slightly larger in some periods, requiring fine-tuning of the prediction results in conjunction with related features such as diet and exercise. When S < 0.90, such as S = 0.85, the predicted trend needs correction, indicating that there is a significant deviation between the predicted curve and the actual curve trend, requiring re-examination of the feature matrix construction or model parameters, optimization, and re-prediction. The evaluation results are stored in conjunction with the corresponding predicted curve, actual curve, and S value for reference in model iteration and optimization.

[0162] Furthermore, the method of finding the source from the dynamic programming algorithm... arrive The optimal paths include:

[0163] Initialize the cumulative distance matrix ,in Indicates from arrive The minimum cumulative distance, ;

[0164] In this embodiment of the invention, a 288×288 cumulative distance matrix C is initialized, where the matrix element C(u,v) represents the minimum cumulative distance from distance matrix D(1,1) to D(u,v). First, the value of C(1,1) is determined by directly assigning it the calculated result of D(1,1). For example, if D(1,1) = 0.7, then C(1,1) = 0.7. The remaining elements of the matrix are initialized to infinity (preset value 100000), and subsequently updated gradually using a recursive formula. During initialization, the matrix dimension information (288×288) and the corresponding time point relationships are stored synchronously to ensure a one-to-one correspondence between C(u,v) and D(u,v), i.e., both correlate the u-th point of the predicted sequence with the v-th point of the actual sequence, avoiding matrix element misalignment.

[0165] Furthermore, the corresponding cumulative distance matrix elements are calculated according to the recursive formula, and a trend constraint factor is introduced to correct the corresponding cumulative distance matrix elements; the correction process specifically involves: calculating the predicted sequence at points... Local trends The actual sequence is at point Local trends The trend similarity function is used to calculate the trend matching degree between two points. ,in To minimize the value and avoid a denominator of zero; construct a trend constraint factor. ,in The basic weighting coefficients are used; simultaneously, the recursive calculation formula for the cumulative distance matrix is ​​modified as follows: By enhancing the matching priority of point pairs with similar local trends through trend constraint factors, the optimal path can better reflect the actual trend changes in blood glucose fluctuations.

[0166] In this embodiment of the invention, the cumulative distance matrix C is traversed in row-major order (starting from u=1, v=1, and sequentially traversing u=1 to 288, v=1 to 288), and the element values ​​are calculated using a recursive formula. First, the local trend of the predicted sequence T_(p_u)=p_u-p_(u-1) (when u≥2, T_(p_1)=0 when u=1) is calculated, such as... =121.2、 =120.5, then T_(p_2)=0.7mg / dL; the actual sequence local trend T_(q_v)=q_v-q_(v-1) (when v≥2, T_(q_1)=0 when v=1), such as =120.5、 =119.8, then T_(q_2)=0.7mg / dL. Set ε=0.001 to avoid a zero denominator, and calculate T_(sim(u,v))=1-|0.7-0.7| / (|0.7|+|0.7|+0.001)=1-0 / 1.401=1 using the trend similarity function. Set the basic weight coefficient α=0.3, and construct the trend constraint factor λ(u,v)=0.3+(1-0.3)×1=1.0. The recursive formula is C(u,v)=D(u,v)+λ(u,v)×min(C(u-1,v),C(u,v-1),C(u-1,v-1)). For example, if D(2,2)=√[(121.2-120.5)²]=0.7 and min(C(1,2),C(2,1),C(1,1))=0.7, then C(2,2)=0.7+1.0×0.7=1.4. This calculation is performed on all elements where u≥2 and v≥2, enhancing the matching priority of similar trend pairs.

[0167] Furthermore, from Start tracing the optimal path in reverse, when At that time, the path point is When equal to At that time, the path point is When equal to At that time, the path point is ;

[0168] In this embodiment of the invention, the optimal path is traced backward from the last element C(288,288) of the cumulative distance matrix C. The result of C(288,288) is 320.5 as mentioned above. First, C(288,288) - D(288,288) = 320.5 - D(288,288). Assuming D(288,288) = 0.5, the difference is 320.0. This difference is compared with C(287,288), C(288,287), and C(287,287). If C(287,288) = 320.0, the path point is determined to be (287,288). Then, C(287,288) - D(287,288) is calculated. Assuming the result is equal to C(286,288), the path point is updated to (286,288). Following this logic, we trace back sequentially, comparing only the C values ​​of the three adjacent points above, left, and upper left of the current point each time, until we reach C(1,1), ensuring that the path is continuous and there are no reverse jumps.

[0169] Furthermore, record the coordinates of all path points to form a complete optimal matching path;

[0170] In this embodiment of the invention, during the reverse tracing process, the coordinates of all path points are recorded in chronological order. The tracing starts from C(288,288), and the first path point recorded is (288,288), followed by (287,288) and (286,288). Up to (1,1). Rearrange the recorded coordinates in reverse order to obtain the complete optimal matching path from (1,1) to (288,288), such as [(1,1),(2,2),(3,3), ...]. [288,288] (if adjacent points have similar trends). The path records are stored in a two-dimensional array, with each element being a (u,v) coordinate pair, and the time point corresponding to each coordinate is also marked (e.g., (1,1) corresponds to 0:00, (2,2) corresponds to 0:05), to ensure that the path is accurately associated with the time dimension, which is convenient for subsequent distance calculation and trend analysis.

[0171] Furthermore, calculate all along the optimal path The sum of these values ​​serves as a measure of the overall distance between the predicted curve and the actual curve.

[0172] In this embodiment of the invention, all coordinate pairs in the optimal matching path are extracted. Corresponding distance matrix elements If the path contains 288 coordinate pairs, then extract all 288. value( =0.7、 =0.7、 , =0.5). These The values ​​are added together sequentially to calculate the sum, i.e., 0.7 + 0.7 + ... +0.5 = 320.5. This sum is the overall distance metric between the predicted curve and the actual curve. The overall distance metric is rounded to one decimal place and stored in conjunction with the optimal path coordinate array and the trend fit S value. It serves as a core indicator for evaluating the accuracy of the predicted curve. The smaller the overall distance metric, the higher the degree of matching between the two curves, and the more reliable the prediction result.

[0173] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.

Claims

1. A method for predicting blood glucose fluctuations based on historical data, characterized in that, Includes the following steps: Step S1: Obtain the user's corresponding historical blood glucose monitoring data, daily behavior data, physiological status data and medical intervention data, and perform time axis alignment and outlier cleaning on various types of historical data to generate a standardized blood glucose-related dataset. Step S2: Extract the basic features and associated impact features corresponding to blood glucose fluctuations based on the standardized blood glucose-related dataset. The basic features include the mean blood glucose drift, intraday fluctuation range, and postprandial peak delay time. The associated impact features include the correlation coefficient between dietary glycemic index and blood glucose response, the dynamic relationship between exercise intensity and blood glucose reduction, and the matching degree between drug efficacy and blood glucose regulation. The basic features and associated impact features are fused in the spatiotemporal dimensions to construct a multidimensional feature matrix of blood glucose fluctuations. Step S3: Construct a dynamic prediction model based on the multidimensional feature matrix of blood glucose fluctuations, so as to learn the mapping relationship between different feature combinations and blood glucose fluctuation trends through the model, and generate a blood glucose fluctuation prediction curve for the user's future preset time period, which includes the time of occurrence of blood glucose peak and trough and the rate of change of fluctuation amplitude. Step S4: Compare and analyze the blood glucose fluctuation prediction curve with the user's actual blood glucose monitoring data, calculate the prediction deviation and trend consistency, and generate the corresponding deviation analysis results. Based on the deviation analysis results, the feature weight allocation of the dynamic prediction model is optimized to generate a personalized blood glucose fluctuation prediction report, which includes risk warning thresholds and intervention suggestion trigger conditions.

2. The method for predicting blood glucose fluctuations based on historical data according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Collect the user's historical blood glucose monitoring data through a continuous glucose monitoring device to obtain the blood glucose value and detection timestamp at each monitoring moment; collect daily behavior data through a smart wearable device, including diet type, food intake, exercise type, exercise intensity, and sleep duration; collect physiological status data through medical testing equipment, including daily weight, resting heart rate, cortisol level, and insulin secretion; obtain medical intervention data through an electronic medical record system, including the type of hypoglycemic drug, frequency of medication, insulin injection dosage, and adjustment time points; Step S12: Standardize the format of the collected historical data to convert timestamps to UTC time format, convert numerical data to a unified unit, and encode text data. Step S13: Use the Isolation Forest algorithm to identify outliers in various types of historical data, including instrument error values ​​in blood glucose monitoring data, logically contradictory records in behavioral data, and jump values ​​in physiological data; use time series interpolation to complete missing data, and generate filler values ​​for missing time periods based on behavioral patterns and blood glucose change patterns of similar days; Step S14: Align and integrate the processed historical data according to the time axis to construct a standardized blood glucose-related dataset that includes time dimension, data type dimension, and feature index dimension. Each record contains multi-source data feature values ​​for the corresponding time point.

3. The method for predicting blood glucose fluctuations based on historical data according to claim 1, characterized in that, Step S2 includes the following steps: Based on historical blood glucose monitoring data in a standardized blood glucose-related dataset, the mean and standard deviation of blood glucose within a preset period are calculated, and the mean blood glucose drift is generated by a mean sliding window to characterize the trend of blood glucose baseline changes. The difference between the maximum and minimum blood glucose values ​​within a day is calculated, and the intraday fluctuation amplitude parameter is generated by combining the time interval of occurrence. The time difference between the postprandial blood glucose peak and the time of meal is extracted to generate the postprandial peak delay time. The mean blood glucose drift, intraday fluctuation range, and postprandial peak delay time are used as the basic features of blood glucose fluctuation to construct a basic feature vector. By combining daily behavioral data and blood glucose monitoring data, the correlation between the glycemic index of different foods and the increase in postprandial blood glucose was calculated using the Pearson correlation coefficient, generating a diet-blood glucose correlation coefficient; based on exercise intensity data and post-exercise blood glucose changes, a nonlinear regression model was used to fit the dynamic relationship curve between exercise intensity and blood glucose reduction; based on medication time, dosage data, and blood glucose change curves, the matching degree parameter between drug concentration half-life and blood glucose regulation effect was calculated. The correlation feature vector was constructed by using the diet-glucose correlation coefficient, the exercise-glucose dynamic relationship curve, and the drug-glucose matching degree parameter as correlation influence features. By fusing the basic feature vector and the associated feature vector through a spatiotemporal attention mechanism, a multidimensional feature matrix of blood glucose fluctuations is generated, which includes a time decay factor and feature importance weights.

4. The method for predicting blood glucose fluctuations based on historical data according to claim 3, characterized in that, The calculation of the mean blood glucose drift using a mean sliding window includes: Set the length and step size of the time sliding window, and determine the window parameters based on the time granularity of the standardized blood glucose-related dataset; Historical blood glucose monitoring data are sequentially incorporated into a time-sliding window, and the average and median blood glucose values ​​within each time-sliding window are calculated to generate a window mean sequence. The difference operation is performed on the window mean sequence of adjacent windows to obtain the mean change between each window, and the mean change rate is calculated in combination with the window time interval. The rate of change of the mean is filtered by exponential smoothing to eliminate short-term fluctuations and retain long-term trend components. The processed mean change rate is normalized to the baseline mean to generate the blood glucose mean drift, where a positive value indicates that the blood glucose baseline has moved upward and a negative value indicates that the blood glucose baseline has moved downward.

5. The method for predicting blood glucose fluctuations based on historical data according to claim 3, characterized in that, The parameters for calculating the matching degree between drug concentration half-life and blood glucose regulation effect based on medication time, dosage data, and blood glucose change curves include: Based on medication time and dosage data from medical intervention data, a pharmacokinetic model is constructed, and the absorption, distribution, metabolism and excretion of drugs in the body are simulated through this pharmacokinetic model. At the same time, the predicted drug concentration values ​​at different time points are calculated, and drug concentration-time curves are generated. The drug concentration half-life parameter is extracted from the drug concentration-time curve, specifically the time required for the drug concentration to drop to half of its initial value, and the effective action period of the drug is determined in combination with the pharmacokinetic characteristics. Align the medication time with the blood glucose change curve on the time axis, and extract the blood glucose change characteristics within the preset time period after medication, including the blood glucose peak decrease, the rate of change of the blood glucose curve slope, and the time for blood glucose to return to the baseline level. A correlation function between drug concentration and blood glucose regulation effect was constructed, with drug concentration half-life as input variable and blood glucose peak reduction, blood glucose curve slope change rate and blood glucose regression time as output variables. The parameters of the correlation function were obtained through nonlinear fitting. The deviation between the theoretical blood glucose regulation effect corresponding to the drug concentration half-life and the actual blood glucose change characteristics is calculated, and the matching degree parameter between the drug concentration half-life and the blood glucose regulation effect is generated by deviation normalization. The matching degree parameter ranges from 0 to 1.

6. The method for predicting blood glucose fluctuations based on historical data according to claim 5, characterized in that, The constructed correlation function between drug concentration and blood glucose regulation effect uses the drug concentration half-life as the input variable and the blood glucose peak reduction, the rate of change of the blood glucose curve slope, and the blood glucose regression time as output variables. The parameters of the correlation function are obtained through nonlinear fitting, including: Define the input and output variables for the correlation function. Let the input variable be the drug concentration half-life. The output variables include the peak blood glucose decrease. , rate of change of blood glucose curve slope and blood glucose return time And construct the corresponding multi-output nonlinear correlation function model. ;in, , , These are the principal coefficients of the correlation function. , , The decay / growth coefficient, , , For adjustment coefficients, , , This is the reference offset; A training dataset was constructed based on the obtained drug concentration half-life, peak blood glucose decrease, rate of change of blood glucose curve slope, and blood glucose regression time. Each sample contained a set of data. Corresponding value, where Extracted from drug concentration-time curves. Results from the analysis of blood glucose change curves after medication; A multi-objective particle swarm optimization algorithm is used to nonlinearly fit the parameters of the correlation function, with the objective function being to minimize the weighted mean square error between the predicted and actual sample values. The specific expression for the objective function is as follows: ; in, For the sample size, , , The predicted value is the correlation function. , , For the actual sample value, , , Let be the error weights for each output variable, and ; Set an iteration termination condition: stop parameter optimization and output the optimal parameter combination when the objective function value is less than a preset error threshold or the number of iterations reaches a maximum threshold. ; By substituting the optimal parameter combination into a multi-output nonlinear correlation function model, the correlation function between drug concentration and blood glucose regulation effect is constructed. This function can be used to determine the correlation between any drug concentration and its half-life. The corresponding blood glucose peak decrease, blood glucose curve slope change rate, and blood glucose regression time prediction value can be directly calculated.

7. The method for predicting blood glucose fluctuations based on historical data according to claim 1, characterized in that, Step S3 includes the following steps: The multidimensional feature matrix of blood glucose fluctuation is divided into a training sample set and a validation sample set in chronological order. The training sample set contains historical feature data and corresponding subsequent blood glucose fluctuation results, while the validation sample set is used for model performance evaluation. A dynamic prediction model based on the Transformer architecture is constructed. The dynamic prediction model includes an input layer, a multi-head self-attention layer, a feature interaction layer, and an output layer. The input layer receives a multi-dimensional feature matrix of blood glucose fluctuations, the multi-head self-attention layer captures the dependencies between features at different time points, the feature interaction layer fuses basic features and related influence features through a gating mechanism, and the output layer generates blood glucose fluctuation curves for future periods through a time series prediction head. An adaptive learning rate optimization algorithm is used to train the dynamic prediction model, so as to adjust the model parameters by minimizing the mean square error between the predicted curve and the actual blood glucose curve, and combine it with an early stopping mechanism to prevent the model from overfitting. The validation sample set is input into the trained dynamic prediction model to generate a blood glucose fluctuation prediction curve for a future preset time period. The blood glucose fluctuation prediction curve includes the blood glucose prediction value, prediction confidence interval and feature contribution index at each time point.

8. The method for predicting blood glucose fluctuations based on historical data according to claim 1, characterized in that, Step S4 includes the following steps: Align the blood glucose fluctuation prediction curve with the user's actual blood glucose monitoring data during the same period, calculate the absolute error and relative error between the predicted value and the actual value at each corresponding time point, and generate an error sequence. The prediction deviation is calculated based on the error sequence, including the mean absolute error, root mean square error and the maximum error value, and the trend fit between the predicted curve and the actual curve is calculated through the dynamic time warping algorithm. Set a deviation threshold and a consistency threshold. When the prediction deviation exceeds the deviation threshold or the trend consistency is lower than the consistency threshold, trigger the model optimization mechanism to adjust the weight allocation of the related influence features in the dynamic prediction model. Based on the optimized dynamic prediction model, a blood glucose fluctuation prediction curve is regenerated. Combined with the user's physiological status data and medical intervention data, the risk warning threshold for abnormal blood glucose fluctuations is determined, and a personalized blood glucose fluctuation prediction report is generated, which includes the risk warning threshold and the intervention suggestion trigger conditions.

9. The method for predicting blood glucose fluctuations based on historical data according to claim 8, characterized in that, The calculation of the trend fit between the predicted curve and the actual curve using the dynamic time warping algorithm includes: Representing the blood glucose fluctuation prediction curve as a time series The actual blood glucose monitoring curve is represented as a time series. ,in and These represent the number of time points for the predicted curve and the actual curve, respectively. Build × Distance matrix , where matrix elements Indicates the predicted sequence number The point and the actual sequence Euclidean distance between points; Find the source using dynamic programming algorithm arrive The optimal path is the one with the minimum sum of distances along the path, where the path constraints satisfy the conditions of monotonicity and continuity. Calculate the ratio of the total distance of the optimal path to the theoretical maximum distance, and convert it into a trend fit S = 1 - (total distance of the optimal path / theoretical maximum distance); The trend consistency is evaluated in segments. When S is greater than or equal to the preset high consistency threshold, the predicted trend is considered highly reliable. When S is between the high and low consistency thresholds, the predicted trend is considered basically reliable. When S is less than the preset low consistency threshold, the predicted trend needs to be corrected.

10. The method for predicting blood glucose fluctuations based on historical data according to claim 9, characterized in that, The method uses dynamic programming to find from arrive The optimal paths include: Initialize the cumulative distance matrix ,in Indicates from arrive The minimum cumulative distance, ; The corresponding cumulative distance matrix elements are calculated using a recursive formula, and a trend constraint factor is introduced to correct these elements. Specifically, the correction process involves calculating the predicted sequence at points... Local trends The actual sequence is at point Local trends The trend similarity function is used to calculate the trend matching degree between two points. ,in To minimize the value and avoid a denominator of zero; construct a trend constraint factor. ,in The basic weighting coefficients are used; simultaneously, the recursive calculation formula for the cumulative distance matrix is ​​modified as follows: By enhancing the matching priority of point pairs with similar local trends through trend constraint factors, the optimal path can better reflect the actual trend changes in blood glucose fluctuations. from Start tracing the optimal path in reverse, when At that time, the path point is When equal to At that time, the path point is When equal to At that time, the path point is ; Record the coordinates of all path points to form a complete optimal matching path; Calculate all on the optimal path The sum of these values ​​serves as a measure of the overall distance between the predicted curve and the actual curve.

Citation Information

Cited By

  • Logistics demand prediction method and system based on artificial intelligence

    CN121961135A

  • Rule engine driving type abnormal mode automatic labeling system and method for dynamic blood glucose

    CN122025193A

  • Drug test-oriented model data standardization processing method and system

    CN122177510A