Diet health index prediction method fusing M-One coding and deep learning

Through M-One encoding and deep learning technology, combined with 1D-CNN and LSTM models, hyperparameters are optimized to improve model performance, solving the efficiency and correlation problems of traditional coding methods when dealing with multi-category features, and achieving efficient seasoning data completion and health indicator prediction.

CN119763832APending Publication Date: 2025-04-04NANTONG UNIV

Patent Information

Application Number
CN202411867372.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

When traditional One-hot encoding processes features with a large number of categories, it leads to a sharp increase in data dimensions, reducing model efficiency, unable to reflect the correlation between discrete feature categories and target variables, failing to capture complex feature interactions, affecting the prediction performance of the model.

Method used

M-One encoding is used to convert discrete features (such as cooking methods and regional differences) into a two-dimensional "influence matrix", dynamically capture the complex relationship between discrete features and target variables, and extract the timing characteristics of numerical data in combination with 1D-CNN, and perform time series modeling through LSTM after integration. At the same time, the sparrow algorithm is used to optimize the size of CNN convolutional layer, the number of LSTM neurons and the learning rate to improve the model performance.

Benefits of technology

It significantly improves feature expression ability and modeling effect, dynamically captures the interactive information between discrete features and target variables, enhances the learning ability of the model, realizes high-precision completion of seasoning data and accurate prediction of health indicators, and provides technical support for personalized health management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763832A_ABST
    Figure CN119763832A_ABST
Patent Text Reader

Abstract

The invention discloses a diet health index prediction method fusing M-One coding and deep learning. The method comprises the steps of collecting diet data of a target user; preprocessing the collected data, and performing multi-dimensional influence matrix M-One coding on discrete features to generate a two-dimensional influence matrix; determining parameters of a three-dimensional data format according to the characteristics of the input data; constructing a CNN-LSTM model, performing convolution operation on the data by using a one-dimensional convolutional neural network 1D-CNN, and extracting features of time series data; optimizing the size of a CNN convolutional layer, the number of neurons of the two LSTM layers and the learning rate through a sparrow algorithm; according to the method, M-One coding and a mixed model of 1D-CNN and LSTM are fused, deep learning optimization of multi-dimensional features is realized, and a scientific basis is provided for user health management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computers, and in particular to a method for predicting dietary health indicators that integrates M-One coding and deep learning. Background Art

[0002] In modern data analysis and machine learning applications, feature encoding technology has an important impact on data modeling. Especially when dealing with missing data, categorical variables, and complex feature interactions, the choice of encoding method directly determines the accuracy and robustness of the model. Although the traditional one-hot encoding method is simple and effective, it has limitations: for features with a large number of categories, the dimension of the encoded data will increase sharply, reducing the efficiency of the model; it cannot reflect the correlation between discrete feature categories and target variables; it fails to capture complex feature interactions, thus affecting the prediction performance of the model. Summary of the invention

[0003] Purpose of the invention: The purpose of the present invention is to provide a method based on M-One coding and sparrow algorithm optimization of convolutional neural network (CNN) and long short-term memory network (LSTM), aiming to efficiently complete the user's seasoning intake data and accurately predict health indicators (such as blood sugar, blood pressure, blood lipids, etc.). The traditional One-hot coding is innovatively extended to M-One coding, and the complex relationship between discrete features (such as cooking methods, regional differences, and dietary frequency) and target variables is dynamically captured through a two-dimensional "influence matrix", and the time series characteristics of numerical data are extracted in combination with 1D-CNN. The integrated features are modeled by LSTM for time series to capture the law of seasoning intake over time. On this basis, the sparrow algorithm (SSA) is used to optimize the CNN convolution layer size, the number of LSTM neurons and the learning rate to achieve a comprehensive improvement in model performance. Finally, the model can complete the missing seasoning data, and predict the user's health indicators based on the completed data, providing technical support for personalized health management. The present invention has significant advantages in feature expression, data completion and health prediction, and provides an innovative solution for the field of health data processing.

[0004] Technical solution: A dietary health index prediction method integrating M-One coding and deep learning of the present invention comprises the following steps:

[0005] Step 1: Collect data on target users’ seasoning intake and factors affecting dietary frequency, cooking methods, and regional differences;

[0006] Step 2: After preprocessing the collected data, filling in missing data and normalizing them, the discrete features of cooking methods and regional differences are encoded using a multidimensional influence matrix M-One to generate a two-dimensional influence matrix to capture the complex relationship between discrete features and target variables;

[0007] Step 3: According to the characteristics of the input data, determine the parameters of the three-dimensional data format, divide it into time series, and divide the numerical data and discrete data into continuous time windows according to the time step;

[0008] Step 4: Construct a CNN-LSTM model and use a one-dimensional convolutional neural network 1D-CNN to perform convolution operations on the seasoning intake and dietary frequency data to extract the features of the time series data; at the same time, input the two-dimensional influence matrix into the convolutional neural network CNN for one-dimensional convolutional neural network 1D-CNN processing to extract the interaction between discrete features and the target variable;

[0009] Step 5: Optimize the size of the CNN convolutional layer, the number of neurons in the two LSTM layers, and the learning rate using the Sparrow algorithm;

[0010] Step 6: Train and evaluate the optimized model, and predict the dietary health indicators of target users based on the model.

[0011] Furthermore, step 1 is specifically as follows: the collected data includes two parts, the first part is numerical features, including oil usage, salt usage, soy sauce usage, sugar usage and eating frequency; the second part is discrete features, including cooking methods and regional differences.

[0012] Furthermore, step 2 specifically includes the following steps:

[0013] Step 2.1: For the numerical characteristics of seasoning intake and dietary frequency, linear interpolation is used to preliminarily fill in the missing data to ensure that the completed data maintains the trend and fluctuation characteristics of the time series. Suppose the original time series data is X = {x1, x2, …, x n}, the processing rules for missing data are:

[0014] If x t If missing, its value is calculated by linear interpolation:

[0015]

[0016] If the data is located at the beginning or end of the sequence, the nearest neighbor method is used to fill it:

[0017]

[0018] Among them, t1 is the position before the non-missing data point, t2 is the position after the non-missing data point, and x t represents the eigenvalue at time t, represents the eigenvalue at time t1, represents the eigenvalue at time t2;

[0019] Step 2.2: Perform normalization or standardization operations on the completed numerical features of condiment intake and dietary frequency to distribute the data on the same scale, so that the model converges faster and improves prediction accuracy. Normalization compresses the data values ​​to the interval [0,1]. The formula is as follows:

[0020]

[0021] Among them, min (X) and max (X) are the minimum and maximum values ​​of the original data sequence, respectively. is the normalized value;

[0022] Standardization adjusts the data to a distribution with a mean of 0 and a standard deviation of 1. The formula is as follows:

[0023]

[0024] Among them, μ is the mean of the original data, σ is the standard deviation of the original data, and x t represents the eigenvalue at time t, x' t is the standardized value;

[0025] Step 2.3: For discrete features including cooking methods and regional differences, M-One coding is used to generate a two-dimensional influence matrix, which is used to capture the interaction between discrete features and target variables. Let discrete features C = {c1, c2, …, c m}, where m is the index of the category, c m represents the mth discrete feature, the target variable Y = {y1,y2,…,y n}, where n is the index of the target variable, y n represents the nth target variable, the element M of the matrix M ij It represents the degree of association between the i-th feature category and the j-th target variable and is defined as follows:

[0026]

[0027] The matrix construction process is row construction, which means each row represents a specific category of cooking methods or regional differences, and column construction, which means each column represents the target variable. The value assignment is based on the data distribution and statistical analysis results to determine whether the feature category has a significant impact on the target variable, and fill the matrix in binary form.

[0028] Furthermore, step 3 specifically includes the following steps:

[0029] Step 3.1: According to the characteristics of the input data, determine the parameters of the three-dimensional data format, and convert the sorted data into the three-dimensional data format of the CNN-LSTM model, with the shape of (number of samples, time step, number of features);

[0030] Step 3.2: Data sorting process, divide the numerical data X into num and discrete data X dis Divide the time step into continuous time windows according to T = 10, and the numerical data X num is the seasoning intake and eating frequency, X num The shape is (1000,5); discrete data X dis is the two-dimensional influence matrix of M-One encoding, X dis The shape is (1000,8), and the combined data is divided into N samples samples, each sample contains T days of data, and the overall feature matrix X = [X num ,X dis ]The shape is (1000,13), reshape X, and the reshaped feature matrix X reshaped = reshape(X[:N samples ×T],(N samples ,T,F)), the final shape is (100,10,13).

[0031] Furthermore, step 4 specifically includes the following steps:

[0032] Step 4.1: Use 1D convolutional neural network 1D-CNN for feature extraction. The convolution layer of the model is designed as follows:

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

[0034]

[0035] Where n is the input length, k is the size of the convolution kernel, s is the step size, and the size of the convolution layer output is calculated. Conv1D output size represents the size of the convolution layer output.

[0036] 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;

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

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

[0039] Pooling layer: The pooling layer uses maximum pooling, the pooling kernel size is 1×2, the step size is 1×2, and the maximum pooling formula is:

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

[0041] Among them, x1,x2,…,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;

[0042] Step 4.2: Flatten layer: The data output by the convolution layer and the pooling layer is flattened into a one-dimensional vector through the Flatten layer, and the data is input into the LSTM layer;

[0043] Step 4.3: LSTM layer: 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 set to 64. The parameter optimization of the LSTM layer uses the SSA algorithm. The LSTM formula is as follows:

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

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

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

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

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

[0049] Among them, f t It is the forget gate, t is the input gate, C t is the cell state, o t is the output gate, h t is the hidden state, W fRepresents 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;

[0050] Dropout layer: Add a Dropout layer after each LSTM layer, and set the dropout rate to 0.3 to prevent the model from overfitting;

[0051] Step 4.4: Fully connected layer Dense: Finally, the output is passed through the fully connected layer to predict the health index. The fully connected layer uses a linear activation function, and the prediction result is the user's health index. The linear activation function formula is:

[0052] y=W·x+b

[0053] Where W is the weight matrix, x is the input vector, and b is the bias vector.

[0054] Furthermore, step 5 specifically includes the following steps:

[0055] Step 5.1: In the sparrow algorithm, set the convolution layer hyperparameters: Number of convolution kernels filters: Set the search range to an integer value between 32 and 128; The convolution kernel size is set to 1×3; LSTM layer hyperparameters: Number of neurons in the first LSTM layer lstm_units_1: Set the search range to an integer value between 32 and 128; Number of neurons in the second LSTM layer lstm_units_2: Set the search range to an integer value between 32 and 128; Learning rate hyperparameters: Learning rate learning_rate: Set the search range to a floating value between 0.0001 and 0.01, indicating the step size of the gradient descent; With the above settings, the search space Bounds of the hyperparameters is:

[0056] Bounds=[(32,128),(32,128),(32,128),(0.0001,0.01)]

[0057] Step 5.2: The evaluation indicators used are mean square error (MSE), root mean square error (RMSE), and mean absolute percentage error (MAPE). During the optimization process, the goal is to minimize these evaluation indicators to achieve the optimal hyperparameter combination.

[0058] Step 5.3: The sparrow algorithm searches the hyperparameter space by simulating the foraging behavior of sparrows. First, a set of candidate solutions is randomly initialized, that is, the initial values ​​of the hyperparameters. For each candidate solution, the model performance is evaluated by the objective function, that is, the evaluation indicators of 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: 128,

[0059] The number of neurons in the first LSTM layer lstm_units_1: 128, the number of neurons in the second LSTM layer lstm_units_2: 128, and the learning rate learning_rate: 0.0039.

[0060] Furthermore, step 6 is as follows: the evaluation index formula is as follows:

[0061] Mean Square Error (MSE):

[0062]

[0063] The smaller the MSE, the smaller the difference between the model's predicted value and the actual observed value, that is, the better the model fit is. i is the true value, is the predicted value;

[0064] Root mean square error RMSE:

[0065]

[0066] The smaller the RMSE, the better the model fit;

[0067] Mean Absolute Percent Error MAPE:

[0068]

[0069] This indicator appears in the form of a percentage, indicating the average percentage of relative error between the predicted value and the actual value.

[0070] The present invention also discloses a computer device, comprising a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method of the present invention.

[0071] The present invention also discloses a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps of the method of the present invention are implemented.

[0072] The present invention also discloses a computer program product, comprising a computer program / instruction, which implements the steps of the method of the present invention when executed by a processor.

[0073] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:

[0074] First, the present invention proposes an innovative M-One encoding method, which significantly improves the expression ability and modeling effect of discrete features. M-One encoding represents the complex relationship between discrete features (such as cooking methods, regional differences) and target variables (seasoning intake) through a two-dimensional "influence matrix", which not only dynamically captures the interactive information between discrete features and target variables, but also enhances the flexibility of feature expression and the learning ability of the model. Compared with traditional One-hot encoding, M-One encoding has strong dynamic expression ability. Through the form of a two-dimensional matrix, it can intuitively express the specific degree of influence of discrete features on target variables; compared with sparse high-dimensional One-hot encoding, M-One encoding is more efficient and compact, with higher information density, which helps to improve the feature learning ability of the model; it is suitable for a variety of discrete features and classification data processing scenarios, especially in user behavior analysis and applications with complex feature interactions.

[0075] Second, the hybrid model of M-One coding is integrated with 1D-CNN and LSTM to achieve deep learning optimization of multi-dimensional features. The present invention constructs a CNN-LSTM hybrid model based on M-One coding, enhances the expression of discrete features through M-One coding, and inputs it into 1D-CNN for convolution processing after fusing it with numerical features, extracts local features, and then captures time series dependencies through LSTM, which significantly improves the data modeling ability. Combining local and global features, 1D-CNN performs convolution processing on numerical data (such as seasoning intake, dietary frequency) to extract local features; the two-dimensional matrix of M-One coding is integrated with numerical features after CNN processing, fully combining the interactive relationship between discrete features and time series features; the time series modeling ability is strong, and the long-term dependencies and time series characteristics of multi-dimensional features are captured through LSTM, so that the model can accurately estimate seasoning intake and predict user health indicators.

[0076] Third, the sparrow algorithm (SSA) is used to optimize model hyperparameters to improve model performance and generalization capabilities. Traditional hyperparameter tuning methods (such as grid search and random search) are inefficient and limited in scope, while the SSA algorithm can globally optimize the key hyperparameters of the model (such as the number of CNN convolution kernels, the number of LSTM neurons, the learning rate, etc.), greatly improving the performance of the model. When searching a large range of hyperparameter spaces, SSA can quickly converge to the global optimal or near-optimal configuration, significantly reducing manual parameter adjustment time and computing costs. The optimized model shows lower MSE, RMSE, and MAPE in prediction accuracy, and is suitable for complex time series modeling and user data prediction scenarios.

[0077] Fourth, it supports the complete process from seasoning data completion to health index prediction. The present invention not only realizes the high-precision completion of seasoning intake data, but also predicts the user's health indicators (such as blood sugar, blood pressure, and blood lipids) by analyzing the completed complete data combined with factors such as dietary frequency, cooking methods, and regional differences. The complex relationship between the user's seasoning intake behavior and health status is modeled through a model to provide a scientific basis for user health management. Accurate health index prediction can help users pay attention to their physical health and improve the quality of healthy life.

[0078] Fifth, compared with existing technologies, M-One coding is more efficient and adaptable to discrete features. Compared with existing methods such as variational mode decomposition (VMD), M-One coding has the following advantages: simple and efficient, no need for complex decomposition steps and precise parameter adjustment, the encoding process is direct and fast; strong adaptability, can be flexibly applied to modeling scenarios of various discrete features; enhanced feature fusion, the combination with CNN and LSTM makes the interactive modeling of discrete features and numerical features more efficient, significantly improving the performance of the overall model. BRIEF DESCRIPTION OF THE DRAWINGS

[0079] Figure 1 It is the overall flow chart of the present invention;

[0080] Figure 2 Process flow chart for M-One coding;

[0081] Figure 3 is the “influence matrix” of feature variables and discrete features;

[0082] Figure 4 is the average evaluation index under different models. DETAILED DESCRIPTION

[0083] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.

[0084] A dietary health index prediction method integrating M-One coding and deep learning of the present invention comprises the following steps:

[0085] Step 1: Collect data to collect data on users’ seasoning intake and factors affecting users’ eating frequency, cooking methods, and regional differences.

[0086] The input data consists of two parts. The first part is numerical features, such as oil usage (g), salt usage (ml), soy sauce usage (ml), sugar usage (g) and dietary frequency (times / day), etc. The second part is discrete features, such as cooking methods and regional differences.

[0087] The second step is to pre-process the collected data and initially complete and normalize the original missing data.

[0088] Step 2.1: For numerical features such as seasoning intake and dietary frequency, linear interpolation is used to preliminarily fill in the missing data to ensure that the completed data maintains the trend and fluctuation characteristics of the time series. Suppose the original time series data is X = {x1, x2, …, x n}, the processing rules for missing data are:

[0089] If x t If missing, its value is calculated by linear interpolation:

[0090]

[0091] If the data is located at the beginning or end of the sequence, the nearest neighbor method is used to fill it:

[0092]

[0093] Among them, t1 is the position before the non-missing data point, t2 is the position after the non-missing data point, and x t represents the eigenvalue at time t, represents the eigenvalue at time t1, Represents the eigenvalue at time t2.

[0094] Step 2.2: Perform normalization or standardization operations on the completed numerical features such as condiment intake and dietary frequency to distribute the data on the same scale, which facilitates faster model convergence and improves prediction accuracy. Normalization compresses the data values ​​to the interval [0,1], and the formula is as follows:

[0095]

[0096] Among them, min(X) and max(X) are the minimum and maximum values ​​of the original data sequence, respectively. is the normalized value.

[0097] Standardization adjusts the data to a distribution with a mean of 0 and a standard deviation of 1. The formula is as follows:

[0098]

[0099] Among them, μ is the mean of the original data, σ is the standard deviation of the original data, and x t represents the eigenvalue at time t, x' t is the standardized value.

[0100] Step 2.3: For discrete features (cooking methods and regional differences), M-One coding is used to generate a two-dimensional "influence matrix", which is used to capture the interaction between discrete features and the target variable (seasoning intake). The M-One coding process flow chart is shown in the figure below: Figure 2 As shown, let the discrete features C = {c1, c2, ..., c m}, where m is the index of the category, c m represents the mth discrete feature, the target variable Y = {y1,y2,…,y n}, where n is the index of the target variable, y n represents the nth target variable. The element M of the matrix M ij It represents the degree of association between the i-th feature category and the j-th target variable and is defined as follows:

[0101]

[0102] The matrix construction process is as follows: row construction means that each row represents a specific category of cooking methods or regional differences, such as "stir-frying", "frying", "deep-frying", "boiling", etc.; column construction means that each column represents the target variable, such as "oil usage", "salt usage" and other seasoning intake; value assignment is based on data distribution and statistical analysis results to determine whether the feature category has a significant impact on the target variable (such as through chi-square test, correlation coefficient and other methods), and fill the matrix in binary form (0 or 1). The construction of the "influence matrix" of feature variables and discrete features is as follows: Figure 3 shown.

[0103] Step 3: Adjust the data input structure and shape the data into a three-dimensional data format that is suitable for the model.

[0104] Step 3.1: Determine the parameters of the three-dimensional data format based on the characteristics of the input data. Convert the sorted data 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 dietary frequency, with a number of 5, and the number of discrete features is 8. The number of features = 5 (numerical features) + 8 (discrete features) = 13. So the number of samples N samples =100, time step T=10, and the number of features is 13.

[0105] Step 3.2: Data sorting process, divide the numerical data X into num and discrete data X dis Divide into continuous time windows according to the time step T = 10. Numerical data X num is the seasoning intake and eating frequency, X num The shape is (1000,5); discrete data X dis The two-dimensional "influence matrix" encoded by M-One, X dis The shape is (1000,8). After combining the data, it is divided into N samples samples, each sample contains T days of data, and the overall feature matrix X = [X num ,X dis ]The shape is (1000,13). Reshape X, and the reshaped feature matrix X reshaped = reshape(X[:N samples ×T],(N samples ,T,F)), the final shape is (100,10,13).

[0106] Step 4: Build a CNN-LSTM model and use 1D-CNN to perform convolution operations on the seasoning intake and dietary frequency data to extract the features of the time series data. At the same time, the two-dimensional "influence matrix" encoded by M-One is input into CNN for 1D-CNN processing to extract the interaction between discrete features and target variables.

[0107] Step 4.1: The present invention uses 1D convolutional neural network (1D-CNN) for feature extraction, and the convolution layer of the model is designed as follows:

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

[0109]

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

[0111] 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.

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

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

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

[0115] 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:

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

[0117] Among them, x1,x2,…,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.

[0118] Step 4.2: 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.

[0119] Step 4.3: 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, add the second LSTM layer, the number of neurons is still set to 64, and the parameters of the LSTM layer are optimized using the SSA algorithm. The core formula of LSTM is as follows:

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

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

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

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

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

[0125] Among them, f t It is the forget gate, t is the input gate, C t is the cell state, o t is the output gate, h t is 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.

[0126] 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.

[0127] Step 4.4: Fully connected (Dense) layer: Finally, the output is passed through the fully connected layer to predict the health index. The fully connected layer uses a linear activation function, and the prediction result is the user's health index. The linear activation function formula is:

[0128] y=W·x+b

[0129] Where W is the weight matrix, x is the input vector, and b is the bias vector.

[0130] Step 5: Use the Sparrow algorithm to optimize the size of the CNN convolutional layer, the number of neurons in the two LSTM layers, and the learning rate.

[0131] Step 5.1: In the Sparrow algorithm, the setting of the hyperparameter search space is crucial, involving the settings of the following main hyperparameters: Convolution layer hyperparameters: Number of convolution kernels (filters): Set the search range to an integer value between 32 and 128; Convolution kernel size (kernel size): Here it is set to 1×3 and remains fixed. LSTM layer hyperparameters: Number of neurons in the first LSTM layer (lstm_units_1): Set the search range to an integer value between 32 and 128; Number of neurons in the second LSTM layer (lstm_units_2): Also set the search range to an integer value between 32 and 128. Learning rate hyperparameters: Learning rate (learning_rate): Set the search range to a floating value between 0.0001 and 0.01, which represents the step size of the gradient descent. With the above settings, the search space (Bounds) of the hyperparameters is:

[0132] Bounds=[(32,128),(32,128),(32,128),(0.0001,0.01)]

[0133] Step 5.2: The objective function is used to evaluate the performance of each set of hyperparameter combinations, which is usually measured by the evaluation indicators of the model. The evaluation indicators used in the present invention are mean square error (MSE), root mean square error (RMSE) and mean absolute percentage error (MAPE). In the optimization process, the goal is to minimize these evaluation indicators to achieve the optimal hyperparameter combination.

[0134] Step 5.3: 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,

[0135] The number of neurons in the first LSTM layer (lstm_units_1): 128, the number of neurons in the second LSTM layer (lstm_units_2): 128, and the learning rate (learning_rate): 0.0039.

[0136] Step 6: Training and evaluation of the optimized model.

[0137] On the basis of 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 prediction results. The formulas of each evaluation indicator are as follows:

[0138] Mean Squared Error (MSE): This indicator is a commonly used indicator to measure the difference between the model prediction value and the actual observation 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 prediction value and the actual observation value, that is, the better the model fit. i is the true value, is the predicted value.

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

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

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

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

[0143]

[0144] From the comparison results in Table 1 above and Figure 4 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 prediction completion results of the algorithm of the present invention (SSA-CNN-LSTM integrated with M-One) are all lower than the evaluation indicators of other models, indicating that the CNN-LSTM regression prediction model completion model optimized by the sparrow algorithm based on the innovative M-One has better time series prediction ability, and accurate health indicator prediction can help users pay attention to their physical health and improve the quality of healthy life.

Claims

1. A dietary health index prediction method integrating M-One coding and deep learning, characterized in that: The steps include: Step 1: Collect data on target users’ seasoning intake and factors affecting dietary frequency, cooking methods, and regional differences; Step 2: After preprocessing the collected data, filling in missing data and normalizing them, the discrete features of cooking methods and regional differences are encoded using a multidimensional influence matrix M-One to generate a two-dimensional influence matrix to capture the complex relationship between discrete features and target variables; Step 3: According to the characteristics of the input data, determine the parameters of the three-dimensional data format, divide it into time series, and divide the numerical data and discrete data into continuous time windows according to the time step; Step 4: Construct a CNN-LSTM model and use a one-dimensional convolutional neural network 1D-CNN to perform convolution operations on the seasoning intake and dietary frequency data to extract the features of the time series data; at the same time, input the two-dimensional influence matrix into the convolutional neural network CNN for one-dimensional convolutional neural network 1D-CNN processing to extract the interaction between discrete features and the target variable; Step 5: Optimize the size of the CNN convolutional layer, the number of neurons in the two LSTM layers, and the learning rate using the Sparrow algorithm; Step 6: Train and evaluate the optimized model, and predict the dietary health indicators of target users based on the model.

2. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 1 is as follows: the collected data consists of two parts. The first part is numerical features, including oil usage, salt usage, soy sauce usage, sugar usage and eating frequency; the second part is discrete features, including cooking methods and regional differences.

3. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 2 specifically includes the following steps: Step 2.1: For the numerical characteristics of seasoning intake and dietary frequency, linear interpolation is used to preliminarily fill in the missing data to ensure that the completed data maintains the trend and fluctuation characteristics of the time series. Suppose the original time series data is X = {x1, x2, …, x n }, the processing rules for missing data are: If x t If missing, its value is calculated by linear interpolation: If the data is located at the beginning or end of the sequence, the nearest neighbor method is used to fill it: Among them, t1 is the position before the non-missing data point, t2 is the position after the non-missing data point, and x t represents the eigenvalue at time t, represents the eigenvalue at time t1, represents the eigenvalue at time t2; Step 2.2: Perform normalization or standardization operations on the completed numerical features of condiment intake and dietary frequency to distribute the data on the same scale, so that the model converges faster and improves prediction accuracy. Normalization compresses the data values ​​to the interval [0,1]. The formula is as follows: Among them, min(X) and max(X) are the minimum and maximum values ​​of the original data sequence, respectively, and x' t is the normalized value; Standardization adjusts the data to a distribution with a mean of 0 and a standard deviation of 1. The formula is as follows: Among them, μ is the mean of the original data, σ is the standard deviation of the original data, and x t represents the eigenvalue at time t, x' t is the standardized value; Step 2.3: For discrete features including cooking methods and regional differences, M-One coding is used to generate a two-dimensional influence matrix, which is used to capture the interaction between discrete features and target variables. Let discrete features C = {c1, c2, …, c m }, where m is the index of the category, c m represents the mth discrete feature, the target variable Y = {y1,y2,…,y n }, where n is the index of the target variable, y n represents the nth target variable, the element M of the matrix M ij It represents the degree of association between the i-th feature category and the j-th target variable and is defined as follows: The matrix construction process is row construction, which means each row represents a specific category of cooking methods or regional differences, and column construction, which means each column represents the target variable. The value assignment is based on the data distribution and statistical analysis results to determine whether the feature category has a significant impact on the target variable, and fill the matrix in binary form.

4. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 3 specifically includes the following steps: Step 3.1: According to the characteristics of the input data, determine the parameters of the three-dimensional data format, and convert the sorted data into the three-dimensional data format of the CNN-LSTM model, with the shape of (number of samples, time step, number of features); Step 3.2: Data sorting process, divide the numerical data X into num and discrete data X dis Divide the time step into continuous time windows according to T = 10, and the numerical data X num is the seasoning intake and eating frequency, X num The shape is (1000,5); discrete data X dis is the two-dimensional influence matrix of M-One encoding, X dis The shape is (1000,8), and the combined data is divided into N samples samples, each sample contains T days of data, and the overall feature matrix X = [X num ,X dis ]The shape is (1000,13), reshape X, and the reshaped feature matrix X reshaped = reshape(X[:N samples ×T],(N samples ,T,F)), the final shape is (100,10,13).

5. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 4 specifically includes the following steps: Step 4.1: Use 1D convolutional neural network 1D-CNN for feature extraction. The convolution layer of the model is designed as follows: First convolutional layer: the number of convolution kernels is set to 16, and the convolution kernel size is 1×3; Where n is the input length, k is the size of the convolution kernel, s is the step size, and the size of the convolution layer output is calculated. Conv1Doutput size represents the size of the convolution layer output. 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; ReLU activation function: ReLU activation function is applied after each convolutional layer, the formula is: f(x)=max(0,x) Pooling layer: The pooling layer uses maximum pooling, the pooling kernel size is 1×2, the step size is 1×2, and the maximum pooling formula is: y=max(x1,x2,…,x k ) Among them, x1,x2,…,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; Step 4.2: Flatten layer: The data output by the convolution layer and the pooling layer is flattened into a one-dimensional vector through the Flatten layer, and the data is input into the LSTM layer; Step 4.3: LSTM layer: 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 set to 64. The parameter optimization of the LSTM layer uses the SSA algorithm. The LSTM 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 ·tan h(W C ·[h t-1 ,x t ]+b C ) the t =σ(W o ·[h t-1 ,x t ]+b o ) h t =o t ·tan h(C t ) Among them, f t It is the forget gate, t is the input gate, C t is the cell state, o t is the output gate, h t is 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; Dropout layer: After each LSTM layer, a Dropout layer is added with a dropout rate of 0.3 to prevent overfitting of the model. Step 4.4: Fully connected layer Dense: Finally, the output is passed through the fully connected layer to predict the health index. The fully connected layer uses a linear activation function, and the prediction result is the user's health index. The linear activation function formula is: y=W·x+b Where W is the weight matrix, x is the input vector, and b is the bias vector.

6. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 5 specifically includes the following steps: Step 5.1: In the sparrow algorithm, set the convolution layer hyperparameters: Number of convolution kernels filters: Set the search range to an integer value between 32 and 128; The convolution kernel size is set to 1×3; LSTM layer hyperparameters: Number of neurons in the first LSTM layer lstm_units_1: Set the search range to an integer value between 32 and 128; Number of neurons in the second LSTM layer lstm_units_2: Set the search range to an integer value between 32 and 128; Learning rate hyperparameters: Learning rate learning_rate: Set the search range to a floating value between 0.0001 and 0.01, indicating the step size of the gradient descent; With the above settings, the search space Bounds of the hyperparameters is: Bounds=[(32,128),(32,128),(32,128),(0.0001,0.01)] Step 5.2: The evaluation indicators used are mean square error (MSE), root mean square error (RMSE), and mean absolute percentage error (MAPE). During the optimization process, the goal is to minimize these evaluation indicators to achieve the optimal hyperparameter combination. Step 5.3: The sparrow algorithm searches the hyperparameter space by simulating the foraging behavior of sparrows. First, a set of candidate solutions is randomly initialized, that is, the initial values ​​of the hyperparameters. For each candidate solution, the model performance is evaluated by the objective function, that is, the evaluation indicators of 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: 128, The number of neurons in the first LSTM layer lstm_units_1: 128, the number of neurons in the second LSTM layer lstm_units_2: 128, and the learning rate learning_rate: 0.0039.

7. According to claim 1, a dietary health index prediction method integrating M-One coding and deep learning is characterized in that: Step 6 is as follows: The evaluation index formula is as follows: Mean Square Error (MSE): The smaller the MSE, the smaller the difference between the model's predicted value and the actual observed value, that is, the better the model fit is. i is the true value, is the predicted value; Root mean square error RMSE: The smaller the RMSE, the better the model fit; Mean Absolute Percent Error MAPE: This indicator appears in the form of a percentage, indicating the average percentage of relative error between the predicted value and the actual value.

8. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method of claim 1.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.

Citation Information

Patent Citations

  • Interference confrontation situation prediction method based on SSA-CNN-LSTM network

    CN116975640A

  • Big data-based nephropathy patient diet condition analysis system and method

    CN117594195A

  • Physical examination abnormal result prediction method and device based on dietary behaviors

    CN118692666A

  • Energy-load-price multi-task joint forecasting method and system for integrated energy systems

    WO2024230493A1

  • KR20210085480A

Cited By

  • Wireless radio frequency positioning method based on multi-source data and convolutional neural network

    CN120908748A