CNN-LSTM missing data estimation method based on sparrow algorithm

Through the CNN-LSTM method based on the sparrow algorithm, combined with sliding window dynamic RMS and one-hot encoding, the convolutional neural network-long and short-term memory network model is optimized, which solves the problem of accurate estimation of the missing part of the user's seasoning intake data, and achieves more efficient data completion and model estimation effects.

CN119646418AInactive Publication Date: 2025-03-18NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411816690.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

It is difficult to accurately estimate the missing parts of user seasoning intake data, especially when considering user behavior characteristics and related factors.

Method used

The CNN-LSTM missing data estimation method based on the sparrow algorithm is adopted. By obtaining seasoning intake data, health index data, cooking method data and regional differences in influencing factors, data completion and feature extraction are carried out. Combining dynamic RMS and one-hot encoding of the sliding window, the hyperparameters of the convolutional neural network-long and short-term memory network model are optimized to achieve the optimal estimation completion result.

Benefits of technology

It significantly improves the accuracy and adaptability of the initial completion of missing data, and is especially suitable for seasoning intake data with periodic and volatile properties, improving the model's estimation effect and processing ability of complex timing data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646418A_ABST
    Figure CN119646418A_ABST
Patent Text Reader

Abstract

The invention discloses a CNN-LSTM missing data estimation method based on a sparrow algorithm, and relates to the field of computers, and the method comprises the following steps: carrying out the complementation processing of original missing data based on obtained data; converting the processed data into a three-dimensional data format, and constructing a convolutional neural network-long and short-term memory network model based on the converted three-dimensional data format in combination with a sparrow algorithm; based on a sparrow algorithm, optimizing the number of convolution kernels of a convolution layer of the convolutional neural network, the number of neurons of a long-short-term memory network layer and a learning rate of the convolutional neural network-long-short-term memory network model, and determining an optimal hyper-parameter combination; and based on the convolutional neural network-long and short-term memory network model, comparing the models before and after optimization of the sparrow algorithm, and outputting an optimal estimation completion result. According to the method, the time and space features are extracted from the diet data of the user and are analyzed, so that personalized healthy diet suggestions are provided for the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a CNN-LSTM missing data estimation method based on a sparrow algorithm. Background Art

[0002] As people's health awareness gradually increases, a scientific and reasonable diet structure has become the focus of public attention. As an indispensable part of the diet, the intake of seasonings directly affects people's nutritional intake and health level. In particular, if the intake of commonly used seasonings such as oil, salt, soy sauce, and sugar exceeds the standard for a long time, it may increase the risk of chronic diseases such as obesity, hypertension, and diabetes.

[0003] Completing the missing parts of the collected user seasoning intake data and conducting a rational analysis of the completed data has become an important research direction in the field of dietary health. Due to the influence of user behavior characteristics and related factors, a single neural network algorithm or estimation algorithm is difficult to accurately estimate and complete the missing data.

[0004] Currently, no effective solution has been proposed for the problems in the related technologies. Summary of the invention

[0005] In view of the problems in the related art, the present invention proposes a CNN-LSTM missing data estimation method based on the sparrow algorithm to overcome the above-mentioned technical problems existing in the existing related technology.

[0006] To this end, the specific technical solution adopted by the present invention is as follows:

[0007] The CNN-LSTM missing data estimation method based on the Sparrow algorithm includes the following steps:

[0008] S1. Obtain data on seasoning intake, health index data, cooking method data, and regional difference influencing factors, and complete the original missing data based on the acquired data;

[0009] S2. Convert the processed data into a three-dimensional data format, and build a convolutional neural network-long short-term memory network model based on the converted three-dimensional data format and combined with the sparrow algorithm;

[0010] S3. Based on the sparrow algorithm, optimize the number of convolution kernels in the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer and the learning rate of the convolutional neural network-long short-term memory network model to determine the optimal hyperparameter combination;

[0011] S4. Based on the convolutional neural network-long short-term memory network model, the mean square error, root mean square error and mean absolute percentage error are used as evaluation indicators. By comparing the model before and after the sparrow algorithm optimization, the optimal estimation completion result is output.

[0012] Furthermore, the acquisition of seasoning intake data, health index data, cooking method data and regional difference influencing factor data, and completion of the original missing data based on the acquired data includes the following steps:

[0013] S11, based on the sliding window dynamics, the obtained seasoning intake data and health index data are used as numerical features, and missing value processing is performed;

[0014] S12, based on one-hot encoding, the obtained cooking method data and regional difference influencing factor data are used as discrete features and represented by a four-bit binary vector;

[0015] S13, performing normalization processing based on the processed numerical features and the discrete features after one-hot encoding to obtain an input matrix;

[0016] Among them, the input expression of the matrix is:

[0017] X input =[x1,x2,…,x T ]

[0018] In the formula, X input represents the input matrix, T represents the time step, x T Indicates a certain time data.

[0019] Furthermore, based on the sliding window dynamics, the obtained seasoning intake data and health index data are used as numerical features, and the missing value processing is performed, including the following steps:

[0020] S111. Remove missing parts in seasoning intake data and health index data;

[0021] S112, dividing the period into large and small periods based on the numerical features after clearing the missing parts, and introducing a sliding window to dynamically calculate and generate a completion value.

[0022] Furthermore, the dynamic expression of the sliding window is as follows:

[0023]

[0024] The formula for calculating and generating the completion value is as follows:

[0025] X 补全 =w s ·X 小周期 +wl ·X 大周期

[0026]

[0027] In the formula, t represents the current time point, k represents the size of the sliding window, and x i Represents the actual data value within the window, RMS t represents the root mean square value of the sliding window, X 小周期 represents the characteristic value calculated for the small-cycle dynamic RMS within the small-cycle range, X 大周期 represents the characteristic value calculated based on the large-cycle dynamic RMS statistics within a large-cycle range, w s Represents the small period feature X 小周期 The associated weight coefficient, w l Represents the large cycle characteristic X 大周期 The associated weight coefficient, X 补全 Represents the estimated value of the missing data in the original data.

[0028] Furthermore, the processing data is converted into a three-dimensional data format, and based on the converted three-dimensional data format and combined with the sparrow algorithm, a convolutional neural network-long short-term memory network model is constructed, which includes the following steps:

[0029] S21. Using a one-dimensional convolutional neural network, perform a convolution operation on the seasoning intake data and health index data converted into a three-dimensional data format to extract features of the time series data;

[0030] S22. Based on the extracted features, they are integrated and input into the long short-term memory network, and the long short-term memory network is optimized by combining the sparrow algorithm to construct a convolutional neural network-long short-term memory network model.

[0031] Furthermore, the convolutional neural network-long short-term memory network model adopts a structure of 11 layers connected in series, including two convolutional layers, an activation function layer, a pooling layer, a flattening layer, two hidden layers, two random drop layers and a fully connected layer.

[0032] Furthermore, the sparrow algorithm optimization formula is as follows:

[0033] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0034] i t =σ(W i ·[h t-1 ,x t ]+b i)

[0035] C t =f t ·C t-1 +i t ·tan h(W C ·[h t-1 ,x t ]+b C )

[0036] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0037] h t =o t tanh(C t )

[0038] In the formula, f t represents the forget gate, i t represents the input gate, C t Indicates the cell state, o t represents the output gate, h t represents the hidden state, W f Represents the weight matrix of the forget gate, W i represents the weight matrix of the input gate, W C Represents the weight matrix of the cell state update part, W o represents the weight matrix of the output gate, h t-1 represents the hidden state of the previous time step, b f represents the bias vector of the forget gate, b i represents the bias vector of the input gate, b C represents the bias vector of the cell state update part, b o represents the bias vector of the output gate and t represents the current time step.

[0039] Furthermore, the method of optimizing the number of convolution kernels of the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer, and the learning rate of the convolutional neural network-long short-term memory network model based on the sparrow algorithm and determining the optimal hyperparameter combination includes the following steps:

[0040] S31, setting a search space for hyperparameters, and evaluating the performance of each set of hyperparameter combinations through the objective function;

[0041] S32. Based on the sparrow algorithm, the hyperparameter space is searched by simulating the sparrow's foraging behavior to confirm the optimal hyperparameter combination.

[0042] Furthermore, the search space for setting the hyperparameters includes setting the number of convolution kernels of the convolutional neural network convolutional layer and the number of neurons in the long short-term memory network layer to integers between 32 and 128, and setting the learning rate to a floating range between 0.0001 and 0.01.

[0043] Furthermore, the method based on the sparrow algorithm, searching the hyperparameter space by simulating the foraging behavior of sparrows, and confirming the optimal hyperparameter combination includes the following steps:

[0044] S321, initializing the initial values ​​of the hyperparameters, and evaluating the convolutional neural network-long short-term memory network model with the current initial value settings using the objective function;

[0045] S322, in each iteration, using the sparrow algorithm to gradually converge and update the position according to the local optimal solution;

[0046] S323. After multiple iterations, the best hyperparameter combination is determined by the sparrow algorithm.

[0047] The beneficial effects of the present invention are:

[0048] 1. The present invention combines the small-cycle dynamic RMS and the large-cycle RMS, taking into account both local and global characteristics. Under the weighted mechanism of dynamic RMS, it significantly improves the accuracy and adaptability of the initial completion of missing data, and is particularly suitable for seasoning intake data with periodicity and volatility. It not only performs more stably in statistical characteristics, but also provides better data support for subsequent model training, thereby improving the estimation effect of the model.

[0049] 2. The present invention combines the time series modeling capabilities of 1D-CNN and LSTM. Compared with the traditional single LSTM or other sequence modeling methods, the present invention introduces a 1D convolutional neural network (1D-CNN) to first extract local features of the seasoning intake and health indicator data, and then input the extracted features into the LSTM network for time series modeling; this can more effectively capture the local features and long-term dependencies in the data, and improve the model's ability to process complex time series data.

[0050] 3. The present invention uses the SSA algorithm to optimize hyperparameters. Compared with traditional manual adjustment or simple grid search methods, the SSA algorithm can more effectively explore a large range of hyperparameter space, reduce the time and cost of manual parameter adjustment, and significantly improve the estimation accuracy of the model; especially in the optimization of the number of convolution kernels, the number of LSTM neurons and the learning rate of the convolutional layer, the SSA algorithm can find the global optimal or near-optimal hyperparameter configuration, thereby significantly improving the model performance.

[0051] 4. The present invention integrates the numerical features of user seasoning intake and user health indicators with the discrete features of cooking methods and regional differences. The one-hot encoding used is a simple, direct and widely applicable feature representation method for classified data, especially for data with discrete classification characteristics (such as cooking methods and regional differences in the present invention). Its advantages are: no additional complexity is introduced (compared with VMD, no additional decomposition operation is required, and the encoding process is simple and fast); enhanced model training efficiency (directly converting classification features into high-dimensional sparse vectors, which is convenient for fusion with 1D-CNN feature extraction, constructing an innovative hybrid feature input method, and significantly enhancing the model estimation ability); wider adaptability (one-hot encoding has low requirements for data preprocessing, is suitable for most discrete features, and does not require precise parameter adjustment like VMD); using one-hot encoding for processing, the model can fully understand the impact of different types of data on seasoning intake, effectively improve the model's learning ability for complex data, and can better adapt to various changes in real scenarios.

[0052] 5. The present invention proposes a hybrid model of a convolutional neural network and a long short-term memory network based on the sparrow algorithm optimization, which can accurately estimate the missing part of the collected user seasoning intake data; by extracting time and space characteristics from the user's dietary data, analyzing the impact of different cooking methods, regional characteristics, user health indicators and other factors on seasoning intake, so as to provide users with personalized healthy diet recommendations; through this model, we can not only complete the missing part of the collected user seasoning intake data, but also identify potential heavy oil and heavy salt intake behaviors, help users optimize the use of seasonings, and reduce the risk of chronic diseases. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0054] Figure 1 is a flow chart of a CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention;

[0055] Figure 2 It is a flowchart of optimizing the CNN-LSTM model using the Sparrow algorithm in the CNN-LSTM missing data estimation method based on the Sparrow algorithm according to an embodiment of the present invention;

[0056] Figure 3This is a flow chart of dynamic RMS weighted preliminary missing value completion in the CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention;

[0057] Figure 4 It is a local overall trend change diagram of the calculation of salt by the sliding window dynamic RMS in the CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention;

[0058] Figure 5 It is a schematic diagram of the working principle of the dynamic periodic sliding window in the CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention;

[0059] Figure 6 It is a one-hot encoded data graph in the CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention;

[0060] Figure 7 It is a visualization comparison diagram of evaluation criteria under different models in the CNN-LSTM missing data estimation method based on the sparrow algorithm according to an embodiment of the present invention. DETAILED DESCRIPTION

[0061] To further illustrate each embodiment, the present invention provides drawings, which are part of the disclosure of the present invention and are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in the field should be able to understand other possible implementations and advantages of the present invention. The components in the figures are not drawn to scale, and similar component symbols are generally used to represent similar components.

[0062] According to an embodiment of the present invention, a CNN-LSTM missing data estimation method based on the Sparrow algorithm is provided.

[0063] The present invention will now be further described with reference to the accompanying drawings and specific embodiments. Figure 1-Figure 7 As shown, according to one embodiment of the present invention, a CNN-LSTM missing data estimation method based on the sparrow algorithm is provided, and the missing data estimation method comprises the following steps:

[0064] S1. Obtain data on seasoning intake, health indicators, cooking methods, and factors affecting regional differences, and complete the original missing data based on the acquired data.

[0065] In one embodiment, the step of acquiring seasoning intake data, health index data, cooking method data, and regional difference influencing factor data, and completing the original missing data based on the acquired data includes the following steps:

[0066] S11. Based on the sliding window dynamics, the acquired seasoning intake data and health index data are used as numerical features, and missing value processing is performed.

[0067] In one embodiment, the method of dynamically using the acquired seasoning intake data and health index data as numerical features and performing missing value processing based on the sliding window includes the following steps:

[0068] S111. Remove missing parts in seasoning intake data and health index data;

[0069] S112, dividing the period into large and small periods based on the numerical features after clearing the missing parts, and introducing a sliding window to dynamically calculate and generate a completion value.

[0070] S12. Based on one-hot encoding, the obtained cooking method data and regional difference influencing factor data are used as discrete features and represented by a four-bit binary vector.

[0071] S13. Perform normalization based on the processed numerical features and the discrete features after one-hot encoding to obtain an input matrix.

[0072] Among them, the input expression of the matrix is:

[0073] X input =[x1,x2,…,x T ]

[0074] In the formula, X input represents the input matrix, T represents the time step, x T Indicates a certain time data.

[0075] In one embodiment, the sliding window dynamic expression is as follows:

[0076]

[0077] The formula for calculating and generating the completion value is as follows:

[0078] X 补全 =w s ·X 小周期 +w l ·X 大周期

[0079]

[0080] In the formula, t represents the current time point, k represents the size of the sliding window, and x i Represents the actual data value within the window, RMS t represents the root mean square value of the sliding window, X 小周期represents the characteristic value calculated for the small-cycle dynamic RMS within the small-cycle range, X 大周期 represents the characteristic value calculated based on the large-cycle dynamic RMS statistics within a large-cycle range, w s Represents the small period feature X 小周期 The associated weight coefficient, w l Represents the large cycle characteristic X 大周期 The associated weight coefficient, X 补全 Represents the estimated value of the missing data in the original data.

[0081] It should be explained that the data collection includes the user's seasoning intake data and the user's health indicators, cooking methods and regional differences. The input data includes two parts. The first part is the numerical features, such as oil usage (g), salt usage (ml), soy sauce usage (ml), sugar usage (g) and body weight (kg), blood pressure (mmHg), blood sugar (mmol / L), etc. The second part is the discrete features, such as cooking methods and regional differences.

[0082] In one embodiment, the collected data is preprocessed, and the original missing data is initially supplemented and normalized. Missing value processing is performed on the original data. By dividing the small-cycle dynamic RMS and the large-cycle dynamic RMS, under the weighted mechanism of the dynamic RMS, the data supplementation result is more consistent with the periodicity and volatility of the actual data, providing higher quality data for subsequent model training, ensuring the integrity of the data, and preliminarily supplementing the missing data, such as Figure 3 As shown in the flow chart. First, the missing parts of the original data are cleared to make the original data continuous. Second, the continuous data is divided into large and small cycles, with the small cycle being 10 days and the large cycle being 30 days, and the sliding window dynamic RMS is introduced.

[0083] In one embodiment, the sliding window dynamic RMS is combined with the cycle, and the small cycle dynamic RMS is used to estimate the short-term missing values ​​and generate more refined completion values; the large cycle dynamic RMS calibrates the small cycle completion value, and the sliding window dynamic RMS local overall trend changes (calculation of salt) are as follows Figure 4 As shown, the specific working principle diagram of the dynamic periodic sliding window is as follows Figure 5 As shown, T small Indicates the small cycle window size, X small Indicates the RMS characteristic value obtained within the time period, T big Indicates the large cycle window size, X big Indicates the RMS eigenvalue obtained within the time period. For each missing value, the supplementary value is calculated based on the weights of the small period and the large period.

[0084] In one embodiment, discrete features are one-hot encoded, such as cooking methods and regional differences, which are processed using a one-hot encoding method. There are four cooking methods ("frying", "deep-frying", "frying", and "boiling"), and there are four regional differences ("northwest region", "Qinghai-Tibet region", "northern region", and "southern region"), which are represented by a four-bit binary vector, such as Figure 6 shown.

[0085] In one embodiment, the numerical features and one-hot encoded discrete features are normalized and combined into an input matrix X input , whose dimensions are (number of samples, time steps, feature dimensions). For time series data, the input format is: X input =[x1,x2,…,x T ], where T means the time step is set to 10 days, x T Indicates a certain time data.

[0086] S2. Convert the processed data into a three-dimensional data format, and build a convolutional neural network-long short-term memory network model based on the converted three-dimensional data format and combined with the sparrow algorithm.

[0087] In one embodiment, the processing data is converted into a three-dimensional data format, and based on the converted three-dimensional data format and combined with the sparrow algorithm, a convolutional neural network-long short-term memory network model is constructed, which includes the following steps:

[0088] S21. Using a one-dimensional convolutional neural network, perform a convolution operation on the seasoning intake data and health index data converted into a three-dimensional data format to extract features of the time series data;

[0089] S22. Based on the extracted features, they are integrated and input into the long short-term memory network, and the long short-term memory network is optimized by combining the sparrow algorithm to construct a convolutional neural network-long short-term memory network model.

[0090] In one embodiment, the convolutional neural network-long short-term memory network model adopts a structure of 11 layers connected in series, including two convolutional layers, an activation function layer, a pooling layer, a flattening layer, two hidden layers, two random drop layers and a fully connected layer.

[0091] In one embodiment, the sparrow algorithm optimization formula is as follows:

[0092] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0093] i t =σ(Wi ·[h t-1 ,x t ]+b i )

[0094] C t =f t ·C t-1 +i t ·tan h(W C ·[h t-1 ,x t ]+b C )

[0095] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0096] h t =o t ·tan h(C t )

[0097] In the formula, f t represents the forget gate, i t represents the input gate, C t Indicates the cell state, o t represents the output gate, h t represents the hidden state, W f Represents the weight matrix of the forget gate, W i represents the weight matrix of the input gate, W C Represents the weight matrix of the cell state update part, W o represents the weight matrix of the output gate, h t-1 represents the hidden state of the previous time step, b f represents the bias vector of the forget gate, b i represents the bias vector of the input gate, b C represents the bias vector of the cell state update part, b o represents the bias vector of the output gate and t represents the current time step.

[0098] It should be explained that the sorted data is converted into a three-dimensional data format suitable for the CNN-LSTM model, with a shape of (number of samples, time step, number of features). The original data set is 1000, and the time step T=10 is selected, which means that each sample contains data from the past 10 days. Then the number of samples is 1000 / 10=100. The numerical features are seasonings ("oil", "salt", "sugar", "soy sauce") and health indicators ("blood pressure", "blood sugar", "weight"), with a total of 7 features, and the number of discrete features is 8. The number of features = 7 (numerical features) + 8 (discrete features) = 15. So the number of samples N samples =100, time step T=10, and number of features is 15.

[0099] In one embodiment, a convolutional neural network-long short-term memory network (CNN-LSTM) model is constructed, and a one-dimensional convolutional neural network (1D-CNN) is used to perform convolution operations on the seasoning intake and health index data, extract features of the time series data, and integrate multi-dimensional features and input them into the long short-term memory network (LSTM);

[0100] The first convolutional layer contains 16 convolution kernels, the convolution kernel size is 1×3, and the activation function is ReLU; the second convolutional layer contains 8 convolution kernels, the convolution kernel size is 1×3, and the activation function is ReLU; the pooling layer uses a 1×2 maximum pooling operation with a step size of 1×2. After the output of the convolutional layer is flattened by the flattening layer, it is input into two fully connected hidden layers. The first hidden layer has 64 neurons and the second hidden layer has 32 neurons. In order to prevent overfitting, two Dropout layers are used, and the dropout rate is 0.3. The final output layer contains 4 neurons, and a linear activation function is used to output the estimated completion results of the intake of four seasonings.

[0101] In one embodiment, a 1D convolutional neural network (1D-CNN) is used for feature extraction, and the convolution layer of the model is designed as follows:

[0102] First convolutional layer: The number of convolution kernels is set to 16, and the convolution kernel size is 1×3.

[0103]

[0104] In the formula, n represents the input length, k represents the size of the convolution kernel, and s represents the step size. This formula calculates the size of the convolution layer output, and Conv1D output size represents the size of the convolution layer output.

[0105] Second convolutional layer: The number of convolution kernels is set to 8, the convolution kernel size is still 1×3, and the output channel is 8.

[0106] ReLU activation function: ReLU activation function is applied after each convolutional layer, the formula is:

[0107] f(x)=max(0,x)

[0108] The ReLU activation function helps introduce nonlinearity, enabling the network to learn complex features.

[0109] Pooling layer: The pooling layer uses maximum pooling with a pooling kernel size of 1×2 and a step size of 1×2 to reduce feature dimensions and extract more representative features. The maximum pooling formula is:

[0110] y=max(x1,x2,…,x k )

[0111] In the formula, x k is the element in the pooling area, x represents the input value of the activation function, f(x) represents the output value of the activation function, y represents the output of the maximum pooling layer, and k represents the number of elements in the pooling window.

[0112] Flatten layer: The data output by the convolution layer and the pooling layer needs to pass through the Flatten layer to flatten the multi-dimensional data into a one-dimensional vector in order to input the data into the LSTM layer.

[0113] LSTM layer design: The first LSTM layer receives the flattened data for time series learning, and the number of neurons is set to 64. After the first LSTM layer, the second LSTM layer is added, and the number of neurons is still set to 64. The parameters of the LSTM layer are optimized using the sparrow algorithm (SSA).

[0114] Dropout layer: After each LSTM layer, a Dropout layer is added with a dropout rate set to 0.3 to prevent the model from overfitting.

[0115] Fully connected layer (Dens layer): Finally, the output is estimated and completed through the fully connected layer. The fully connected layer uses a linear activation function, and the estimated completion result is the seasoning intake. The linear activation function formula is:

[0116] y=W·x+b

[0117] Among them, W represents the weight matrix, x represents the input vector, and b represents the bias vector.

[0118] S3. Based on the sparrow algorithm, optimize the number of convolution kernels in the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer, and the learning rate of the convolutional neural network-long short-term memory network model to determine the optimal hyperparameter combination.

[0119] In one embodiment, the method of optimizing the number of convolution kernels of the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer, and the learning rate of the convolutional neural network-long short-term memory network model based on the sparrow algorithm, and determining the optimal hyperparameter combination includes the following steps:

[0120] S31. Set the search space for hyperparameters and evaluate the performance of each set of hyperparameter combinations through the objective function.

[0121] In one embodiment, the search space for setting the hyperparameters includes setting the number of convolution kernels of the convolutional neural network convolutional layer and the number of neurons in the long short-term memory network layer to integers between 32 and 128, and setting the learning rate to a floating range between 0.0001 and 0.01.

[0122] S32. Based on the sparrow algorithm, the hyperparameter space is searched by simulating the sparrow's foraging behavior to confirm the optimal hyperparameter combination.

[0123] In one embodiment, the method of searching the hyperparameter space by simulating the foraging behavior of sparrows based on the sparrow algorithm and confirming the optimal hyperparameter combination includes the following steps:

[0124] S321, initializing the initial values ​​of the hyperparameters, and evaluating the convolutional neural network-long short-term memory network model with the current initial value settings using the objective function;

[0125] S322, in each iteration, using the sparrow algorithm to gradually converge and update the position according to the local optimal solution;

[0126] S323. After multiple iterations, the best hyperparameter combination is determined by the sparrow algorithm.

[0127] It should be explained that the size of the CNN convolutional layer, the number of neurons in the two LSTM layers, and the learning rate are optimized through the Sparrow algorithm.

[0128] In one embodiment, the search space is first set for each hyperparameter. Specifically, the number of convolution kernels and the number of neurons in the LSTM layer are set to integers between 32 and 128, and the learning rate is set to a floating range between 0.0001 and 0.01. The objective function is used to evaluate the performance of each set of hyperparameter combinations, usually measured by the evaluation indicators of the model. Such as the mean square error (MSE), root mean square error (RMSE) and mean absolute percentage error (MAPE) of the model. In the optimization process, the goal is to minimize these evaluation indicators to achieve the optimal hyperparameter combination.

[0129] In one embodiment, the sparrow algorithm searches the hyperparameter space by simulating the foraging behavior of sparrows. First, a set of candidate solutions (i.e., the initial values ​​of the hyperparameters) are randomly initialized. For each candidate solution, the model performance is evaluated by the objective function, that is, the evaluation indicators such as MSE, RMSE, and MAPE based on the current hyperparameter settings are calculated. In each iteration, the sparrow algorithm updates the position according to the local optimal solution and gradually converges to the optimal solution. After multiple iterations, the best hyperparameter combination found by the sparrow search algorithm is: number of convolution kernels (filters): 128, number of neurons in the first LSTM layer (lstm_units_1): 128, number of neurons in the second LSTM layer (lstm_units_2): 128, learning rate (learning_rate): 0.0047.

[0130] S4. Based on the convolutional neural network-long short-term memory network model, the mean square error, root mean square error and mean absolute percentage error are used as evaluation indicators. By comparing the model before and after the sparrow algorithm optimization, the optimal estimation completion result is output.

[0131] It should be explained that, based on the sparrow algorithm optimization model in step 5, in order to verify the effect of the present invention, the mean square error (MSE), root mean square error (RMSE) and mean absolute percentage error (MAPE) are used as evaluation indicators, and the LSTM, CNN-LSTM and SSA-LSTM models are compared to output the estimation completion results.

[0132] Mean Squared Error (MSE): This indicator is a commonly used indicator to measure the difference between the model estimate and the actual observed value. It is used to evaluate the degree of fit of the model on the given data. The smaller the MSE, the smaller the difference between the model estimate and the actual observed value, that is, the better the model fit. i represents the true value, Indicates an estimated value.

[0133] Root Mean Square Error (RMSE): This indicator is a commonly used indicator to measure the accuracy of the estimation model. The smaller the RMSE, the better the model fit.

[0134] Mean Absolute Percent Error (MAPE): This indicator appears in the form of a percentage, indicating the average percentage of relative error between the estimated value and the actual value.

[0135] The collected data is input into the CNN-LSTM model optimized by the sparrow algorithm of the present invention. The experimental results are compared with LSTM, CNN-LSTM and SSA-LSTM as shown in Table 1.

[0136] Table 1 Comparison of evaluation indicators of seasoning intake under different models

[0137]

[0138]

[0139] From the comparison results in Table 1 above and Figure 7 It can be seen from the visualization results that the mean square error (MSE), root mean square error (RMSE) and mean absolute percentage error (MAPE) in the estimation and completion results of the CNN-LSTM model optimized by the sparrow algorithm of the present invention are lower than the evaluation indicators of other models, indicating that the CNN-LSTM regression estimation model completion model optimized by the sparrow algorithm based on the preliminary completion of the sliding window dynamic RMS data has better time series estimation ability, and is more suitable for the estimation and completion data of the user's seasoning intake, to help users optimize the seasoning intake and reduce the risk of chronic diseases.

[0140] In summary, with the aid of the above technical solution of the present invention, the present invention proposes a hybrid model of a convolutional neural network and a long short-term memory network based on the sparrow algorithm optimization, which can accurately estimate the missing part of the collected user seasoning intake data. By extracting time and space features from the user's dietary data, analyzing the effects of different cooking methods, regional characteristics, user health indicators and other factors on seasoning intake, personalized healthy diet recommendations are provided to users. Through this model, we can not only complete the missing parts of the collected user seasoning intake data, but also identify potential heavy oil and heavy salt intake behaviors, help users optimize the use of seasonings, and reduce the risk of chronic diseases.

[0141] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. The CNN-LSTM missing data estimation method based on the sparrow algorithm is characterized by: The missing data estimation method includes the following steps: S1. Obtain data on seasoning intake, health index data, cooking method data, and regional difference influencing factors, and complete the original missing data based on the acquired data; S2. Convert the processed data into a three-dimensional data format, and build a convolutional neural network-long short-term memory network model based on the converted three-dimensional data format and combined with the sparrow algorithm; S3. Based on the sparrow algorithm, optimize the number of convolution kernels in the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer and the learning rate of the convolutional neural network-long short-term memory network model to determine the optimal hyperparameter combination; S4. Based on the convolutional neural network-long short-term memory network model, the mean square error, root mean square error and mean absolute percentage error are used as evaluation indicators. By comparing the model before and after the sparrow algorithm optimization, the optimal estimation completion result is output.

2. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 1, characterized in that: The method of obtaining seasoning intake data, health index data, cooking method data, and regional difference influencing factor data, and completing the original missing data based on the obtained data includes the following steps: S11, based on the sliding window dynamics, the obtained seasoning intake data and health index data are used as numerical features, and missing value processing is performed; S12, based on one-hot encoding, the obtained cooking method data and regional difference influencing factor data are used as discrete features and represented by a four-bit binary vector; S13, performing normalization processing based on the processed numerical features and the discrete features after one-hot encoding to obtain an input matrix; Among them, the input expression of the matrix is: X input =[x1,x2,…,x T ] Where, X input represents the input matrix, T represents the time step, x T Indicates a certain time data.

3. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 2, characterized in that: The method of dynamically using the seasoning intake data and health index data obtained based on the sliding window as numerical features and performing missing value processing includes the following steps: S111. Remove missing parts in seasoning intake data and health index data; S112, dividing the period into large and small periods based on the numerical features after clearing the missing parts, and introducing a sliding window to dynamically calculate and generate a completion value.

4. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 3, characterized in that: The dynamic expression of the sliding window is as follows: The formula for calculating and generating the completion value is as follows: X 补全 =w s ·X 小周期 +w l ·X 大周期 w s +w l = 1 and w s , w l ∈(0, 1) In the formula, t represents the current time point, k represents the size of the sliding window, and x i Represents the actual data value within the window, RMS t represents the root mean square value of the sliding window, X 小周期 represents the characteristic value calculated for the small-cycle dynamic RMS within the small-cycle range, X 大周期 represents the characteristic value calculated based on the large-cycle dynamic RMS statistics within a large-cycle range, w s Represents the small period feature X 小周期 The associated weight coefficient, w l Represents the large cycle characteristic X 大周期 The associated weight coefficient, X 补全 Represents the estimated value of the missing data in the original data.

5. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 1, characterized in that: The processing data is converted into a three-dimensional data format, and based on the converted three-dimensional data format and combined with the sparrow algorithm, a convolutional neural network-long short-term memory network model is constructed, which includes the following steps: S21. Using a one-dimensional convolutional neural network, perform a convolution operation on the seasoning intake data and health index data converted into a three-dimensional data format to extract features of the time series data; S22. Based on the extracted features, they are integrated and input into the long short-term memory network, and the long short-term memory network is optimized by combining the sparrow algorithm to construct a convolutional neural network-long short-term memory network model.

6. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 5, characterized in that: The convolutional neural network-long short-term memory network model adopts a structure of 11 layers connected in series, including two convolutional layers, an activation function layer, a pooling layer, a flattening layer, two hidden layers, two random dropout layers and a fully connected layer.

7. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 6, characterized in that: The sparrow algorithm optimization formula is as follows: f t =σ(W f ·[h t-1 ,x t ]+b f ) i t =σ(W i ·[h t-1 ,x t ]+b i ) C t =f t ·C t-1 +i t ·tanh(W C ·[h t-1 ,x t ]+b C ) the t =σ(W o ·[h t-1 ,x t ]+b o ) h t =o t ·tanh(C t ) In the formula, f t represents the forget gate, i t represents the input gate, C t Indicates the cell state, o t represents the output gate, h t represents the hidden state, W f Represents the weight matrix of the forget gate, W i represents the weight matrix of the input gate, W C Represents the weight matrix of the cell state update part, W o represents the weight matrix of the output gate, h t-1 represents the hidden state of the previous time step, b f represents the bias vector of the forget gate, b i represents the bias vector of the input gate, b C represents the bias vector of the cell state update part, b o represents the bias vector of the output gate and t represents the current time step.

8. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 1, characterized in that: The method of optimizing the number of convolution kernels of the convolutional neural network convolution layer, the number of neurons in the long short-term memory network layer and the learning rate of the convolutional neural network-long short-term memory network model based on the sparrow algorithm and determining the optimal hyperparameter combination includes the following steps: S31, setting a search space for hyperparameters, and evaluating the performance of each set of hyperparameter combinations through the objective function; S32. Based on the sparrow algorithm, the hyperparameter space is searched by simulating the sparrow's foraging behavior to confirm the optimal hyperparameter combination.

9. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 8, characterized in that: The search space for setting the hyperparameters includes setting the number of convolution kernels of the convolutional neural network convolutional layer and the number of neurons of the long short-term memory network layer to integers between 32 and 128, and setting the learning rate to a floating range between 0.0001 and 0.

01.

10. The CNN-LSTM missing data estimation method based on the sparrow algorithm according to claim 8, characterized in that: The method of searching the hyperparameter space by simulating the foraging behavior of sparrows based on the sparrow algorithm and confirming the optimal hyperparameter combination includes the following steps: S321, initializing the initial values ​​of the hyperparameters, and evaluating the convolutional neural network-long short-term memory network model with the current initial value settings using the objective function; S322, in each iteration, using the sparrow algorithm to gradually converge and update the position according to the local optimal solution; S323. After multiple iterations, the best hyperparameter combination is determined by the sparrow algorithm.