CN117153339A - Diet recommendation method and system based on decision tree machine learning - Google Patents
Diet recommendation method and system based on decision tree machine learning Download PDFInfo
- Publication number
- CN117153339A CN117153339A CN202311211071.1A CN202311211071A CN117153339A CN 117153339 A CN117153339 A CN 117153339A CN 202311211071 A CN202311211071 A CN 202311211071A CN 117153339 A CN117153339 A CN 117153339A
- Authority
- CN
- China
- Prior art keywords
- meal recommendation
- health state
- recommendation model
- meal
- trained
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003066 decision tree Methods 0.000 title claims abstract description 35
- 238000000034 method Methods 0.000 title claims abstract description 34
- 238000010801 machine learning Methods 0.000 title claims abstract description 25
- 235000005911 diet Nutrition 0.000 title claims description 14
- 230000037213 diet Effects 0.000 title claims description 11
- 235000012054 meals Nutrition 0.000 claims abstract description 118
- 230000036541 health Effects 0.000 claims abstract description 49
- 238000012549 training Methods 0.000 claims abstract description 49
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 31
- 238000007637 random forest analysis Methods 0.000 claims abstract description 27
- 238000007781 pre-processing Methods 0.000 claims abstract description 7
- 238000012360 testing method Methods 0.000 claims description 11
- 230000009467 reduction Effects 0.000 claims description 9
- 238000011156 evaluation Methods 0.000 claims description 8
- 201000010099 disease Diseases 0.000 claims description 7
- 208000037265 diseases, disorders, signs and symptoms Diseases 0.000 claims description 7
- 230000008569 process Effects 0.000 claims description 7
- 230000003862 health status Effects 0.000 claims description 4
- 208000004262 Food Hypersensitivity Diseases 0.000 claims description 3
- 206010016946 Food allergy Diseases 0.000 claims description 3
- 239000008280 blood Substances 0.000 claims description 3
- 210000004369 blood Anatomy 0.000 claims description 3
- 238000000605 extraction Methods 0.000 claims description 3
- 235000020932 food allergy Nutrition 0.000 claims description 3
- 238000001356 surgical procedure Methods 0.000 claims description 3
- 239000013589 supplement Substances 0.000 claims 1
- 230000035764 nutrition Effects 0.000 abstract description 6
- 235000016709 nutrition Nutrition 0.000 abstract description 6
- 238000007726 management method Methods 0.000 abstract description 2
- 238000002790 cross-validation Methods 0.000 description 6
- 239000008186 active pharmaceutical agent Substances 0.000 description 4
- 238000013528 artificial neural network Methods 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 4
- 238000009826 distribution Methods 0.000 description 4
- 238000005457 optimization Methods 0.000 description 4
- 230000009469 supplementation Effects 0.000 description 4
- 230000000378 dietary effect Effects 0.000 description 3
- 235000013305 food Nutrition 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000005070 sampling Methods 0.000 description 3
- 238000003556 assay Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000007477 logistic regression Methods 0.000 description 2
- 238000012706 support-vector machine Methods 0.000 description 2
- 206010020772 Hypertension Diseases 0.000 description 1
- 206010028980 Neoplasm Diseases 0.000 description 1
- 201000011510 cancer Diseases 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000007635 classification algorithm Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 206010012601 diabetes mellitus Diseases 0.000 description 1
- 238000003745 diagnosis Methods 0.000 description 1
- 235000020979 dietary recommendations Nutrition 0.000 description 1
- 230000004069 differentiation Effects 0.000 description 1
- 208000010643 digestive system disease Diseases 0.000 description 1
- 208000019622 heart disease Diseases 0.000 description 1
- 208000026278 immune system disease Diseases 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 208000017169 kidney disease Diseases 0.000 description 1
- 208000019423 liver disease Diseases 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 235000021139 traditional diet Nutrition 0.000 description 1
- 239000013598 vector Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G16—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
- G16H—HEALTHCARE INFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR THE HANDLING OR PROCESSING OF MEDICAL OR HEALTHCARE DATA
- G16H20/00—ICT specially adapted for therapies or health-improving plans, e.g. for handling prescriptions, for steering therapy or for monitoring patient compliance
- G16H20/60—ICT specially adapted for therapies or health-improving plans, e.g. for handling prescriptions, for steering therapy or for monitoring patient compliance relating to nutrition control, e.g. diets
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/213—Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/243—Classification techniques relating to the number of classes
- G06F18/24323—Tree-organised classifiers
Landscapes
- Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Evolutionary Biology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Health & Medical Sciences (AREA)
- Epidemiology (AREA)
- General Health & Medical Sciences (AREA)
- Public Health (AREA)
- Medical Informatics (AREA)
- Primary Health Care (AREA)
- Nutrition Science (AREA)
- Medical Treatment And Welfare Office Work (AREA)
Abstract
The invention discloses a meal recommendation method and a meal recommendation system based on decision tree machine learning, which belong to the technical field of meal recommendation and nutrition management and comprise the following steps: acquiring the health state of a user; preprocessing the health state to obtain the complete health state of the user; extracting the characteristics of the complete health state, and converting the complete health state into health state data; and inputting the health state data into a trained meal recommendation model to obtain a meal recommendation result. The machine learning random forest algorithm training model is adopted, so that the meal recommendation problem is converted into the classification prediction problem in the machine learning, the traditional mode of requiring professional nutrition personnel planning is replaced, personalized meal recommendation can be provided for the user more effectively, and the problems of high subjectivity and low efficiency of the traditional meal recommendation are solved.
Description
Technical Field
The invention relates to the technical field of nutrition management, in particular to a meal recommendation method and a meal recommendation system based on decision tree machine learning.
Background
With the improvement of living standard and health consciousness, people have an enhanced nutrition consciousness at present, but face various foods, normal people mostly consult with nutritionists or inquire related advice on related food websites to conduct daily diet planning, and the ill people mostly depend on professional knowledge and experience of the nutritionists or doctors. In a hospital setting, it is important to provide the hospitalized patient with the appropriate meal type than other populations. Recommending a proper diet for the condition of a patient is a highly specialized task requiring specialized medical nutrition knowledge, and in addition, the workload of medical staff can be increased due to the huge number of inpatients. Therefore, the existing hospitalization diet recommendation mode has the problems of low accuracy, high subjectivity and low efficiency.
Accordingly, it would be desirable to provide a method and system that automatically analyzes user needs and recommends appropriate meals.
Disclosure of Invention
In view of the above, the invention provides a meal recommendation method and system based on decision tree machine learning, which can automatically analyze user requirements and recommend proper meals.
In order to achieve the above object, the present invention provides the following technical solutions:
in one aspect, the invention provides a meal recommendation method based on decision tree machine learning, comprising the following steps:
acquiring the health state of a user;
preprocessing the health state to obtain the complete health state of the user;
extracting the characteristics of the complete health state, and converting the complete health state into health state data;
and inputting the health state data into a trained meal recommendation model to obtain a meal recommendation result.
Preferably, the training process of the meal recommendation model comprises the following steps:
step 1: constructing a data set by using health state data of different users, and dividing the data set into a training set and a testing set;
step 2: training the meal recommendation model by using a decision tree algorithm modified random forest algorithm;
step 3: evaluating the trained meal recommendation model by adopting accuracy rate, precision rate, recall rate and F1 score; if the accuracy, the precision, the recall rate and the F1 score of the trained meal recommendation model are all larger than the preset value, training of the meal recommendation model is completed; if any one index of the accuracy, the precision, the recall and the F1 score of the trained meal recommendation model is smaller than or equal to a preset value, replacing the meal recommendation model by the trained meal recommendation model, adjusting parameters of the random forest algorithm, and repeating the step 2 and the step 3 for the trained meal recommendation model.
Preferably, replacing the meal recommendation model with the trained meal recommendation model further comprises:
calculating the accuracy of the trained meal recommendation model and the reduction amplitude of the accuracy of the meal recommendation model before the training, if the reduction amplitude is smaller than the threshold value, replacing the meal recommendation model with the trained meal recommendation model, and if the reduction amplitude is larger than or equal to the threshold value, continuing to adopt the meal recommendation model before the training.
Preferably, the adjusting parameters of the random forest algorithm specifically includes:
increasing the number of trees in the random forest;
judging whether the meal recommendation model is subjected to fitting, if so, reducing the depth of the tree in the random forest, and increasing the minimum number of samples of leaf nodes;
increasing feature randomness;
and adjusting weight parameters of different categories to balance the performance of the meal recommendation model in the training set.
Preferably, the health status of the user includes: age, sex, height, weight, blood type, underlying disease, test results, duration after surgery, history of food allergy.
Preferably, the preprocessing comprises missing value supplementation, and the missing value supplementation is filled by adopting a default value filling method.
On the other hand, the invention also provides a meal recommendation system based on decision tree machine learning, which comprises the following steps:
the input module is used for acquiring the health state of a user;
the pretreatment module is used for carrying out pretreatment on the health state;
the feature extraction module is used for converting the preprocessed health state into health state data;
the recommendation module is used for recommending the diet to the health state data by using the trained diet recommendation model;
and the output module is used for outputting the meal recommendation result of the recommendation module.
The system further comprises:
the data set module is used for acquiring health state data of different users to construct a data set and dividing the data set into a training set and a testing set;
the training module is used for training the meal recommendation model by using a decision tree algorithm modified random forest algorithm;
the evaluation module is used for evaluating the trained meal recommendation model and calculating the accuracy, the precision, the recall rate and the F1 score of the trained meal recommendation model;
and the judging module is used for judging whether the trained meal recommendation model is trained according to the accuracy rate, the precision rate, the recall rate and the F1 score.
Compared with the prior art, the invention discloses a meal recommendation method and a meal recommendation system based on decision tree machine learning, which are characterized in that a machine learning random forest algorithm training model is adopted to convert meal recommendation problems into classification prediction problems in machine learning, so that a traditional mode of requiring professional nutrition personnel planning is replaced, and personalized meal recommendation can be provided for users more effectively. Solves the problems of large subjectivity, low cost and high quality of traditional diet recommendation inefficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a meal recommendation method in the invention;
FIG. 2 is a structural frame diagram of a meal recommendation system of the present invention;
fig. 3 is a schematic diagram of the model training structure of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention adopts a random forest machine learning algorithm, trains the model from the case characteristics of the historic inpatients and the corresponding meal conditions, and deploys the model on a web server, thereby automatically providing the meal recommendation function.
The embodiment of the invention discloses a meal recommendation method based on decision tree machine learning, which is shown in fig. 1 and comprises the following steps:
the health status of the user is obtained.
And preprocessing the health state to obtain the complete health state of the user.
And extracting the characteristics of the complete health state, and converting the complete health state into health state data.
For medical history, diseases affecting dietary diagnosis are screened, stored numerically in stages, forming feature vectors, and during dietary recommendation, the following diseases may require specific dietary adjustments. For diseases involving staging, we will note at the stage designation: hypertension (0, 1), diabetes (0, 1), kidney disease (stage index: 1, 2, 3, 4), heart disease (0, 1), liver disease (0, 1), digestive system disease (0, 1), cancer (0, 1), immune system disease (0, 1);
wherein 0 represents no disease, the staged numbers represent severity sequentially from 1, and no staged numbers 1 represent presence. The meals used as tags are numbered in turn according to the package type, replacing the specific dishes.
And inputting the health state data into a trained meal recommendation model to obtain a meal recommendation result.
Preferably, the training process of the meal recommendation model comprises the following steps:
step 1: constructing a data set by using health state data of different users, and dividing the data set into a training set and a testing set; 70% of the data were used as training sets and 30% of the data were used as test sets.
Step 2: training a meal recommendation model by using a random forest algorithm of an improved decision tree algorithm; the specific process comprises the following steps: training using a random forest classification algorithm of the scikit-learn library in python;
the parameters of the specific algorithm are as follows:
the algorithm generates n=1000 decision trees;
the splitting standard adopts the non-purity of the kene, and the formula is:
where C is the number of categories, P i Is the proportion of samples in the node that belong to the i-th class.
The value of the non-purity of the kene ranges from 0 to 0.5, when the non-purity of the kene of a node is low, the samples in the node tend to belong to the same category, and the purity is high. When the keni is not pure, the sample distribution in the node is more mixed and the purity is lower.
The maximum depth of the tree is 20;
the minimum number of samples required for internal node splitting is 2;
the minimum number of samples required for a leaf node is 1;
the feature number considered at each split is sqrt (n_features), where n_features refers to the feature number;
the maximum number of leaf nodes is not limited;
building a tree using the replaced samples;
the code was trained using the random forest classification algorithm of the scikit-learn library in python.
Step 3: in the model evaluation phase, we will use various metrics to comprehensively evaluate the quality of the predicted outcome to ensure that our automated meal recommendation system has high accuracy and practicality in hospitalized patients. Evaluating the trained meal recommendation model by adopting accuracy, precision, recall and F1 score; if the accuracy, the precision, the recall and the F1 score of the trained meal recommendation model are all larger than the preset value, training of the meal recommendation model is completed; if any index of the accuracy, the precision, the recall and the F1 score of the trained meal recommendation model is smaller than or equal to a preset value, replacing the meal recommendation model with the trained meal recommendation model, adjusting parameters of a random forest algorithm, and repeating the step 2 and the step 3 for the trained meal recommendation model until the target is reached.
The following are the specific formulas of four main evaluation indexes we use:
accuracy (Accuracy): accuracy refers to the ratio between the number of samples that the model correctly predicts and the total number of samples. It measures the accuracy of the model in the whole sample.
The calculation formula is as follows: accuracy= (number of predicted correct samples)/(total number of samples).
Precision (Precision): the accuracy rate refers to the proportion of the actual positive case among all the samples predicted by the model to be positive cases. It focuses on the accuracy of model predictions as positive examples.
The calculation formula is as follows: accuracy = (true case)/(true case + false positive).
Recall (Recall): recall refers to the proportion of all actual positive examples for which the model successfully predicts as positive examples. It concerns the degree of coverage of the model alignment.
The calculation formula is as follows: recall = (true case)/(true case + false case).
F1 fraction: the F1 score is a harmonic average of the accuracy and recall that comprehensively considers the accuracy and recall of the model. The F1 score applies to the case of unbalanced class distribution.
The calculation formula is as follows: f1 =2 x (precision x recall)/(precision + recall);
by calculating the above index, we can obtain a comprehensive assessment of the predicted outcome of the automated meal recommendation system. The high accuracy rate indicates that the overall prediction performance of the model is good, the high accuracy rate indicates that the model has high accuracy for predicting the positive example, the high recall rate indicates that the model has high coverage degree for the positive example, and the high F1 fraction integrates the accuracy rate and the recall rate, so that the performance of the model can be more comprehensively evaluated.
For example: the specific evaluation values of the four main evaluation indexes used can be set as follows:
accuracy (Accuracy): in general, an accuracy of more than 80% to 90% is considered excellent. 80% is adopted for the case.
Precision (Precision): the higher the accuracy, the better, and in general, an accuracy higher than 80% to 90% can be considered excellent. For this case, the training standard was 80%.
Recall (Recall): the higher the recall, the better, and in general, a recall higher than 80% to 90% may be considered excellent. For this case, the training standard was 80%.
F1 fraction: the F1 score comprehensively considers the accuracy and recall, and in general, an F1 score higher than 0.8 to 0.9 can be considered excellent. The present case is rated at 0.8.
By means of the evaluation indexes, the prediction capability of the automatic meal recommendation system can be objectively and comprehensively evaluated, and therefore accurate and reliable meal recommendation can be provided in a hospital environment by the system.
Preferably, replacing the meal recommendation model with the trained meal recommendation model further comprises:
calculating the accuracy of the trained meal recommendation model and the reduction amplitude of the accuracy of the meal recommendation model before the training, if the reduction amplitude is smaller than a threshold value, replacing the meal recommendation model with the trained meal recommendation model, and if the reduction amplitude is larger than or equal to the threshold value, continuing to adopt the meal recommendation model before the training. Wherein the threshold may be set to 5%.
Preferably, the parameters for adjusting the random forest algorithm specifically include:
increasing the number of trees in the random forest;
judging whether the meal recommendation model is subjected to fitting, if so, reducing the depth of the tree in the random forest, and increasing the minimum number of samples of the leaf nodes;
increasing feature randomness;
and adjusting the weight parameters of different categories to balance the performance of the meal recommendation model in the training set.
The initial parameters used for model training are given in the foregoing, if the training result is not ideal, the model needs to optimize the training parameters before deployment, the optimization adopts the following strategy, and after the optimization is completed, the parameters are not changed in online training:
adjusting the number of decision trees (n_identifiers): the number of decision trees in the random forest can affect the performance of the model. By adjusting this parameter, the complexity and accuracy of the model can be controlled to some extent. In this case, the number defaults to 1000, and the number of samples can be increased appropriately when the model accuracy is insufficient due to the increase of the number of samples. Generally, increasing the number of decision trees can improve the stability and accuracy of the model.
Adjusting the maximum depth (max_depth) of the decision tree: controlling the maximum depth of the decision tree can limit the complexity of the model, avoiding overfitting. The model can be made more generalizable by limiting the depth of the tree, in which case the maximum depth can be adjusted after the fitting is found. The appropriate max_depth value is selected by cross-validation.
The adjustment node splitting criterion (criterion): in decision tree node splitting, the use of genie unrepeatation (gini) or information gain (entropy) may be chosen as the splitting criterion. Different criteria may be applicable to different problems, and model performance may be optimized by trying different criteria.
Feature sampling strategy (max_features): each time the random forest splits a node, a part of features are randomly selected from the feature set to divide. By adjusting this parameter, the number of features used per decision tree can be controlled, thereby increasing the diversity of the model.
Adjust leaf node minimum number of samples (min_samples_leaf): setting the minimum number of samples of leaf nodes can avoid the model from being too complex and reduce the risk of overfitting. By increasing this value, the leaf node can be made more stable.
Cross-validation was used for parameter tuning: through cross-validation, different combinations of superparameters may be systematically tried to find the optimal parameter configuration. Common cross-validation methods include k-fold cross-validation, and the like.
Feature importance selection: random forests can calculate the importance level of each feature. Features with more differentiation and influence can be selected according to the ordering of feature importance, so that feature dimensions are reduced, and model efficiency and accuracy are improved.
Processing unbalanced data: if the data set is class unbalanced, some method may be used, such as over-sampling, under-sampling, or using class weights, to balance the data distribution for better model results.
Monitoring generalization capability of the model: in the optimization process, the performance of the model on unseen data is evaluated by using methods such as cross-validation, so as to ensure that the optimization is not only aimed at the training set, but also can adapt to new data.
Preferably, the health status of the user includes: age, sex, height, weight, blood type, underlying disease, test results, duration after surgery, history of food allergy.
Preferably, the preprocessing comprises missing value supplementation, and the missing value supplementation is filled by adopting a default value filling method.
Such as medical history data processing: for medical history data, we will use a method of filling in default values. Specifically, if medical history data is not recorded, we treat it as none, filling in the corresponding default values. For example, for medical history data that is not recorded, we fill it as "none" to preserve this missing information.
When the processing assay results are missing, we will use a median fill method. For a numerical assay result, we will use the median of all known data to fill in missing values. Thus, the overall distribution characteristic of the data can be maintained, and the influence of extreme values on the filling result is avoided.
In summary, during the feature engineering stage, the missing values of the medical history data and the test results are processed according to the method to ensure the integrity and accuracy of the data, and provide reliable feature input for the model.
In the actual application process, the production environment service deployment comprises the following steps:
a) On-line model training and deployment
Training a model: model training is performed on a suitable training data set using methods such as machine learning decision tree algorithms. And obtaining an optimized automatic meal recommendation model after training. The model is compared with the model result of the last version on the training set, and if the accuracy rate is not greatly reduced (5%), the original version is replaced;
and (3) deriving a model: the trained model is exported into a suitable format for subsequent deployment and use.
Web server configuration: configuring an environment on a Web server, and ensuring that the server can run Python and related dependency libraries;
deployment model: deploying the exported model file to a Web server for access and call through an API;
updating data: the data updated regularly is updated into the database.
b) Web API design
Api is written in Python language.
Prediction function: patient information is received as input, the loaded model is invoked, and a predicted meal package number is returned as output.
Feature conversion: the incoming patient information is preprocessed and feature transformed to conform to the features of the training data for input to the model for prediction.
Model loading: the trained model is loaded in the API and is ready for prediction.
Api uses, and the application programs (web and app) used by the healthcare personnel will integrate the calling functions of the above APIs, and a matched dietary scheme is made according to the specific situation of the patient. In the process, the following correspondence is established between the package number and the actual dish to satisfy the instruction of doctors or the selection of patients: each package number corresponds to dishes and staple foods contained in three meals, and simultaneously provides gram number options of large, medium and small portions for a doctor to specify according to needs or for a patient to select by himself.
In another aspect, the present invention further provides a meal recommendation system based on decision tree machine learning, as shown in fig. 2, including:
the input module is used for acquiring the health state of a user;
the pretreatment module is used for carrying out pretreatment on the health state;
the feature extraction module is used for converting the preprocessed health state into health state data;
the recommendation module is used for recommending the diet to the health state data by using the trained diet recommendation model;
and the output module is used for outputting the meal recommendation result of the recommendation module.
As shown in fig. 3, the system further includes:
the data set module is used for acquiring health state data of different users to construct a data set and dividing the data set into a training set and a testing set;
the training module is used for training the meal recommendation model by using a decision tree algorithm modified random forest algorithm;
the evaluation module is used for evaluating the trained meal recommendation model and calculating the accuracy, the precision, the recall rate and the F1 score of the trained meal recommendation model;
the judging module is used for judging whether the trained meal recommendation model is trained according to the accuracy rate, the precision rate, the recall rate and the F1 score.
In automated meal recommendation systems, there are many other machine learning classification algorithms that can be used instead of or in addition to random forest algorithms. The selection of the appropriate algorithm depends on the data characteristics, the problem requirements, and the algorithm performance. The following are some alternative algorithms that may be considered: decision Trees (Decision Trees), support vector machines (Support VectorMachines, SVM), logistic regression (Logistic Regression), K nearest neighbor algorithms (K-NearestNeighbors, KNN), naive Bayes (Naive Bayes), artificial Neural Networks (Artificial Neural Networks, ANN), gradient-lifting Trees (Gradient Boosting Trees), GBoost, lightGBM, catBoost, and Neural Networks (Neural Networks).
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (8)
1. A meal recommendation method based on decision tree machine learning, comprising the steps of:
acquiring the health state of a user;
preprocessing the health state to obtain the complete health state of the user;
extracting the characteristics of the complete health state, and converting the complete health state into health state data;
and inputting the health state data into a trained meal recommendation model to obtain a meal recommendation result.
2. A method of meal recommendation based on decision tree machine learning as claimed in claim 1 wherein the training process of the meal recommendation model comprises:
step 1: constructing a data set by using health state data of different users, and dividing the data set into a training set and a testing set;
step 2: training the meal recommendation model by using a decision tree algorithm modified random forest algorithm;
step 3: evaluating the trained meal recommendation model by adopting accuracy rate, precision rate, recall rate and F1 score; if the accuracy, the precision, the recall rate and the F1 score of the trained meal recommendation model are all larger than the corresponding preset values, the training of the meal recommendation model is completed; if any one index of the accuracy, the precision, the recall and the F1 score of the trained meal recommendation model is smaller than or equal to a preset value, replacing the meal recommendation model by the trained meal recommendation model, adjusting parameters of the random forest algorithm, and repeating the step 2 and the step 3 for the trained meal recommendation model.
3. A method of meal recommendation based on decision tree machine learning according to claim 2, further comprising, before replacing said meal recommendation model with said trained meal recommendation model:
calculating the accuracy of the trained meal recommendation model and the reduction amplitude of the accuracy of the meal recommendation model before the training, if the reduction amplitude is smaller than the threshold value, replacing the current meal recommendation model with the trained meal recommendation model, and if the reduction amplitude is larger than or equal to the threshold value, continuing to adopt the meal recommendation model before the training.
4. A meal recommendation method based on decision tree machine learning according to claim 2, characterized in that adjusting parameters of the random forest algorithm specifically comprises:
increasing the number of trees in the random forest;
judging whether the meal recommendation model is subjected to fitting, if so, reducing the depth of the tree in the random forest, and increasing the minimum number of samples of leaf nodes;
increasing feature randomness;
and adjusting weight parameters of different categories to balance the performance of the meal recommendation model in the training set.
5. A method of meal recommendation based on decision tree machine learning as claimed in claim 1 wherein said user's health status comprises: age, sex, height, weight, blood type, underlying disease, test results, duration after surgery, history of food allergy.
6. A method of meal recommendation based on decision tree machine learning as claimed in claim 1 wherein said preprocessing includes missing value supplements that are padded with default value padding.
7. A decision tree machine learning based meal recommendation system comprising:
the input module is used for acquiring the health state of a user;
the pretreatment module is used for carrying out pretreatment on the health state;
the feature extraction module is used for converting the preprocessed health state into health state data;
the recommendation module is used for recommending the diet to the health state data by using the trained diet recommendation model;
and the output module is used for outputting the meal recommendation result of the recommendation module.
8. A decision tree machine learning based meal recommendation system in accordance with claim 7 further comprising:
the data set module is used for acquiring health state data of different users to construct a data set and dividing the data set into a training set and a testing set;
the training module is used for training the meal recommendation model by using a decision tree algorithm modified random forest algorithm;
the evaluation module is used for evaluating the trained meal recommendation model and calculating the accuracy, the precision, the recall rate and the F1 score of the trained meal recommendation model;
and the judging module is used for judging whether the trained meal recommendation model is trained according to the accuracy rate, the precision rate, the recall rate and the F1 score.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311211071.1A CN117153339A (en) | 2023-09-19 | 2023-09-19 | Diet recommendation method and system based on decision tree machine learning |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311211071.1A CN117153339A (en) | 2023-09-19 | 2023-09-19 | Diet recommendation method and system based on decision tree machine learning |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117153339A true CN117153339A (en) | 2023-12-01 |
Family
ID=88886771
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311211071.1A Pending CN117153339A (en) | 2023-09-19 | 2023-09-19 | Diet recommendation method and system based on decision tree machine learning |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117153339A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106778836A (en) * | 2016-11-29 | 2017-05-31 | 天津大学 | A kind of random forest proposed algorithm based on constraints |
CN108198603A (en) * | 2017-12-12 | 2018-06-22 | 昆明亿尚科技有限公司 | A kind of nutrition dietary based on personal physical examination information recommends method |
CN108899073A (en) * | 2018-06-29 | 2018-11-27 | 重庆邮电大学 | A kind of intelligent health diet recommender system of combination mobile terminal |
CN114613471A (en) * | 2022-03-08 | 2022-06-10 | 平安国际智慧城市科技股份有限公司 | Diet scheme generation method, device, equipment and medium based on artificial intelligence |
CN115422443A (en) * | 2022-08-17 | 2022-12-02 | 哈尔滨商业大学 | Recipe recommendation method, terminal device and storage medium |
-
2023
- 2023-09-19 CN CN202311211071.1A patent/CN117153339A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106778836A (en) * | 2016-11-29 | 2017-05-31 | 天津大学 | A kind of random forest proposed algorithm based on constraints |
CN108198603A (en) * | 2017-12-12 | 2018-06-22 | 昆明亿尚科技有限公司 | A kind of nutrition dietary based on personal physical examination information recommends method |
CN108899073A (en) * | 2018-06-29 | 2018-11-27 | 重庆邮电大学 | A kind of intelligent health diet recommender system of combination mobile terminal |
CN114613471A (en) * | 2022-03-08 | 2022-06-10 | 平安国际智慧城市科技股份有限公司 | Diet scheme generation method, device, equipment and medium based on artificial intelligence |
CN115422443A (en) * | 2022-08-17 | 2022-12-02 | 哈尔滨商业大学 | Recipe recommendation method, terminal device and storage medium |
Non-Patent Citations (2)
Title |
---|
熊光明,于会龙,龚建伟,邸慧军著: "智能车辆理论与应用:慕课版 第2版", 31 December 2021, 《北京理工大学出版社》, pages: 23 - 24 * |
赵仁乾,田建中,叶本华作: "金融商业算法建模基于Python和SAS", 31 October 2021, 《机械工业出版社》, pages: 236 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111292853B (en) | Multi-parameter-based cardiovascular disease risk prediction network model and construction method thereof | |
Lutimath et al. | Prediction of heart disease using machine learning | |
AU2012245343B2 (en) | Predictive modeling | |
EP4280225A2 (en) | Determining an optimal wellness regime | |
Kumar et al. | Empirical evaluation of the performance of feature selection approaches on random forest | |
CN108511057A (en) | Transfusion volume model foundation and prediction technique, device, equipment and its storage medium | |
Choubey et al. | GA_J48graft DT: a hybrid intelligent system for diabetes disease diagnosis | |
US20230222364A1 (en) | Method of and system for generating a longevity element and an instruction set for a longevity element plan | |
US20210089965A1 (en) | Data Conversion/Symptom Scoring | |
KR102657384B1 (en) | Method for organizing and recommending diet based on personal preference | |
CN112052874A (en) | Physiological data classification method and system based on generation countermeasure network | |
Guruprasad et al. | Heart disease prediction using machine learning techniques | |
Ahammad | Risk factor identification for stroke prognosis using machine-learning algorithms | |
US20210391063A1 (en) | System and method for dynamic workload balancing based on predictive analytics | |
Mehta et al. | Newfangled approach for early detection and prevention of ischemic heart disease using data mining | |
CN117153339A (en) | Diet recommendation method and system based on decision tree machine learning | |
US11687813B2 (en) | Systems and methods for ranking alimentary combinations using machine-learning | |
KR20180061551A (en) | Method and apparatus of similar case clustering for future health trends prediction | |
US8666766B2 (en) | System and methods for simulating future medical episodes | |
US12001796B2 (en) | Methods and systems for personal recipe generation | |
US20220004955A1 (en) | Method and system for determining resource allocation instruction set for meal preparation | |
KR20180061553A (en) | System and method for predicting future health trends through prediction models based on similar case clustering | |
Rachitha et al. | MWSMO: Multi-objective whale slime mold optimization based food recommendation system for diabetes patient using GAN model | |
US11599921B2 (en) | System and method for determining an alimentary preparation provider | |
US11894116B1 (en) | Apparatus for extending longevity and a method for its use |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |