Method, apparatus, device and medium for recommending a diet for an inpatient
By combining unique heat encoding and a fully connected model with food ratings and favorites data, a personalized food recommendation list is generated, which solves the problem of insufficient multi-dimensional data processing in existing technologies and meets the health management needs of hospitalized patients.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RUIJIN HOSPITAL AFFILIATED TO SHANGHAI JIAO TONG UNIV SCHOOL OF MEDICINE
- Filing Date
- 2026-03-26
- Publication Date
- 2026-06-30
AI Technical Summary
Existing dietary recommendation methods lack efficient integration and processing mechanisms when dealing with the multidimensional health data of hospitalized patients, resulting in recommendations that lack scientific rigor and personalization, and fail to effectively combine behavioral data such as dietary scores and collection records with physical condition data.
Discrete features of hospitalized patients are processed by one-hot encoding and then input into a fully connected model for entity embedding, combined with food ratings and favorites data. A dual collaborative filtering recommendation algorithm is used to generate personalized food recommendation lists, taking into account user physique and food similarity.
It enables personalized dietary recommendations, reduces the risk of improper diet affecting recovery, and meets the clinical rehabilitation and health management needs of hospitalized patients.
Smart Images

Figure CN122314261A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, and in particular to a method, apparatus, equipment, and medium for providing dietary recommendations to hospitalized patients. Background Technology
[0002] Current dietary recommendation methods generally suffer from insufficient multi-dimensional data processing capabilities: the health information of hospitalized patients covers multiple types of data, including discrete text (such as past medical history and allergy history) and continuous numerical data (such as height, weight, and smoking history). Existing models lack efficient fusion processing mechanisms, either ignoring the semantic value of discrete features or failing to effectively adapt to the quantitative requirements of continuous features. At the same time, most systems do not integrate behavioral data such as dietary scores and collection records of hospitalized patients with physical condition and health data, resulting in recommendation results that are both unscientific (not matching physical condition) and unpersonalized (not conforming to preferences). Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for dietary recommendations for hospitalized patients, which combines constitution identification with dietary recommendations, thereby reducing the risk of inappropriate diet affecting recovery. The specific solution is as follows: Firstly, this application discloses a dietary recommendation method for hospitalized patients, applied to a target medical client, including: One-hot encoding is performed on the discrete features in the collected physical characteristics of the target hospitalized users to obtain encoded features, and the encoded features and the continuous features in the physical characteristics of the users are input into the target fully connected model. The encoded features are embedded into entities using the target fully connected model to obtain target embedded features. Based on the target embedded features and the continuous features, the target fully connected model is used to predict the physical characteristics of the target hospitalized user to determine the target predicted physical condition of the target hospitalized user. Based on the first food rating data of the target hospitalized user and the second food rating data of the target hospitalized user's target neighboring users, the target predicted rating of the target hospitalized user for each preset food is determined, and the food similarity between each preset food is determined based on the current food collection data of each hospitalized user, and the food preference prediction value of the target hospitalized user for the target food is determined based on the food similarity. Based on the target prediction score and the food preference prediction value, a target food recommendation list corresponding to the target predicted physique is generated.
[0004] Optionally, the step of performing one-hot encoding on the discrete features in the collected physical characteristics of the target hospitalized users to obtain encoded features includes: The physical characteristics of target hospitalized users are collected through a pre-set physical fitness identification questionnaire. The discrete features in the physical fitness characteristics are then one-hot encoded to transform the discrete features into corresponding one-hot encoded vectors. These one-hot encoded vectors are then used as encoded features corresponding to the discrete features.
[0005] Optionally, the step of embedding entities into the encoded features using the target fully connected model to obtain target embedded features, and then using the target fully connected model to predict the physical characteristics of the target hospitalized user based on the target embedded features and the continuous features, to determine the target predicted physical condition of the target hospitalized user, includes: The target fully connected model performs entity embedding on the encoded features based on the preset embedding layer weight matrix, the one-hot encoding dimension corresponding to the encoded features, and the preset embedding vector dimension to obtain the target embedded features; The continuous features are normalized to obtain normalized features, and the normalized features are concatenated with the target embedded features to obtain concatenated features. The spliced features are integrated by a preset fully connected layer, and the integrated features are normalized to obtain the predicted probability of each predicted physical condition for the target hospitalized user. The target predicted physical condition of the target hospitalized patient is determined based on the predicted probability.
[0006] Optionally, determining the target predicted rating of the target hospitalized user for each preset food based on the first food rating data of the target hospitalized user and the second food rating data of the target hospitalized user's target neighboring users includes: Collect the first food rating data of the target hospitalized patient, and collect the second food rating data of a preset number of target neighboring patients corresponding to the target hospitalized patient through a preset bubble algorithm; Calculate the rating similarity between the target hospitalized user and the target adjacent user based on the first food rating data and the second food rating data, respectively. Based on the rating similarity and the first food rating data, the target predicted rating of the target hospitalized user for each preset food is determined.
[0007] Optionally, the step of determining the food similarity between preset foods based on the current food collection data of each hospitalized user, and determining the predicted food preference value of the target hospitalized user for the target food based on the food similarity, includes: Collect food collection data of each current hospitalized patient, and determine the number of users who have collected each preset food based on the food collection data, so as to determine the food similarity between each preset food based on the number of users who have collected it; The target hospitalized user's target food collection set is determined, and several similarities are determined between the target food and various target food collections in the target food collection set. The sum of the several similarities is used as the predicted food preference value of the target hospitalized user for the target food.
[0008] Optionally, before generating the target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value, the method further includes: Determine the current login status of the target inpatient user on the target medical client; If the login status is not logged in, then based on the preset rating order, several target ratings corresponding to the preset recommendation quantity threshold are selected from the target predicted ratings, and the first target recommended food corresponding to the several target ratings is determined; the preset rating order is the order of rating values from high to low; Based on a preset order of collection volume, a second target recommended food corresponding to a preset recommended quantity threshold is selected from the preset foods; the preset order of collection volume is from high to low. Remove the foods that the target hospitalized user has rated and saved from the first target recommended foods and the second target recommended foods to generate a first food recommendation list; If the login status is "logged in", then the first target recommended food and the second target recommended food are weighted and mixed based on preset weights, and a second food recommendation list is generated based on the mixed result.
[0009] Optionally, generating a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value includes: Identify the unrecommended foods corresponding to the target predicted physique, and remove the unrecommended foods from the second food recommendation list to obtain the target food recommendation list corresponding to the target predicted physique.
[0010] Secondly, this application discloses a dietary recommendation device for hospitalized patients, applied to a target medical client, comprising: The feature encoding module is used to perform one-hot encoding on the discrete features in the collected physical characteristics of the target hospitalized users to obtain encoded features, and input the encoded features and the continuous features in the physical characteristics of the users into the target fully connected model. The physical fitness prediction module is used to embed entities into the encoded features through the target fully connected model to obtain target embedded features, and to predict the physical fitness features of the target hospitalized user based on the target embedded features and the continuous features through the target fully connected model to determine the target predicted physical fitness of the target hospitalized user. The diet data determination module is used to determine the target predicted score of the target hospitalized user for each preset food based on the first food score data of the target hospitalized user and the second food score data of the target hospitalized user's target neighboring users, and to determine the food similarity between each preset food based on the current food collection data of each hospitalized user, and to determine the predicted food preference value of the target hospitalized user for the target food based on the food similarity. The recommendation list generation module is used to generate a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value.
[0011] Thirdly, this application discloses an electronic device, including: Memory, used to store computer programs; A processor is used to execute the computer program to implement the dietary recommendation method for hospitalized patients as described above.
[0012] Fourthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned dietary recommendation method for hospitalized patients.
[0013] In this application, discrete features in the collected physical characteristics of target hospitalized users can be one-hot encoded to obtain encoded features. These encoded features, along with continuous features in the physical characteristics, are then input into a target fully connected model. The encoded features are then embedded into entities using the target fully connected model to obtain target embedded features. Based on these target embedded features and the continuous features, the target fully connected model predicts the physical characteristics of the target hospitalized user to determine their target predicted physical condition. Based on the target hospitalized user's first food rating data and the second food rating data of their target neighboring users, the target predicted rating for each preset food is determined. Furthermore, based on the current food collection data of each hospitalized user, the food similarity between the preset foods is determined, and based on the food similarity, the target hospitalized user's predicted food preference value for the target food is determined. Finally, based on the target predicted rating and the predicted food preference value, a target food recommendation list corresponding to the target predicted physical condition is generated.
[0014] Therefore, the method of this application can perform one-hot encoding on the discrete features of the target hospitalized user, and input the obtained encoded features and the user's continuous features into a fully connected model to perform entity embedding on the encoded features. Based on the obtained target embedded features and continuous features, the target predicted constitution of the user is predicted. Based on the food rating data of the user and neighboring users, the predicted rating of the user for each preset food is predicted, and the food similarity between each preset food is determined according to the food collection data of current hospitalized users, so as to determine the user's predicted preference value for the target food. Based on the predicted rating and the predicted preference value, a target food recommendation list corresponding to the target predicted constitution is generated. In this way, the constitution identification results can be combined with the dietary recommendation process, so that the recommendation scheme can not only meet the personalized needs, but also meet the clinical rehabilitation and health management needs of hospitalized patients, reducing the risk of rehabilitation being affected by improper diet. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0016] Figure 1 This application discloses a flowchart of a dietary recommendation method for hospitalized patients. Figure 2 This is a schematic diagram of a target fully connected model structure disclosed in this application; Figure 3 This is a schematic diagram of an initial fully connected model disclosed in this application; Figure 4 This is a schematic diagram of an entity embedding layer in a target fully connected model disclosed in this application; Figure 5 This is a schematic diagram of the loss variation curve of a model disclosed in this application; Figure 6 This is a schematic diagram of a dietary recommendation device for hospitalized patients disclosed in this application; Figure 7 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Currently, dietary recommendation methods generally suffer from insufficient multi-dimensional data processing capabilities. Since the health information of hospitalized patients includes both continuous numerical values and discrete text, existing models lack efficient fusion processing mechanisms. Furthermore, most systems do not integrate behavioral data such as dietary scores and collection records of hospitalized patients with their physical condition and health data, resulting in recommendation results that lack both scientific rigor and personalization.
[0019] To overcome the aforementioned technical problems, this application discloses a method, device, equipment, and medium for dietary recommendations for hospitalized patients. This method can combine the results of physical constitution identification with the dietary recommendation process, so that the recommendation plan can meet both personalized needs and the clinical rehabilitation and health management needs of hospitalized patients, thereby reducing the risk of rehabilitation being affected by improper diet.
[0020] See Figure 1 As shown, this embodiment of the invention discloses a dietary recommendation method for hospitalized patients, applied to a target medical client, including: Step S11: Perform one-hot encoding on the discrete features in the collected physical characteristics of the target hospitalized users to obtain encoded features, and input the encoded features and the continuous features in the physical characteristics of the users into the target fully connected model.
[0021] In this embodiment, it is necessary to collect the physical characteristics of the target hospitalized users. It should be noted that this embodiment uses a physical constitution identification questionnaire to collect these characteristics. Specifically, a pre-designed physical constitution identification questionnaire is used to collect the physical characteristics of the target hospitalized users to obtain a health information form. This questionnaire, customized using Traditional Chinese Medicine (TCM), contains 33 questions: mental health, lifestyle, sleep quality, sleep duration, past medical history, surgical or trauma history, allergic drugs, drug allergies, allergic foods, food allergies, history of genetic diseases, vaccination history, respiratory system abnormalities, circulatory system abnormalities, digestive system abnormalities, urinary system abnormalities, hematopoietic system abnormalities, endocrine and metabolic system abnormalities, nervous system abnormalities, musculoskeletal system abnormalities, questions about cold and heat, sweating, pain, head, body, chest, and abdomen, ears and eyes, dietary preferences, daily smoking amount, smoking duration, daily alcohol consumption, alcohol consumption duration, sleep duration, height, and weight. The first 26 questions have discrete text values, while the last 7 questions have continuous values. The TCM physical constitution scale assigns a 5-level score to each pre-designed question for statistical analysis. The health information form is filled out using a combination of options and notes. It should be noted that, due to the presence of discrete data in the collected data, it cannot be directly input into a deep learning model. Therefore, a deep learning model needs to be designed to quantify the textual information in the health information form and achieve physical condition identification.
[0022] Furthermore, it is necessary to perform one-hot encoding on the discrete features of the collected physical characteristics of the target hospitalized users to obtain encoded features. These encoded features, along with the continuous features from the physical characteristics, are then input into the target fully connected model. Specifically, one-hot encoding is required to transform the discrete features into corresponding one-hot encoded vectors, which are then used as the encoded features corresponding to the discrete features. It should be noted that since the first 26 features are discrete text, i.e., discrete features, they cannot be directly used as input to the fully connected neural network. Therefore, one-hot encoding is required to process them and obtain encoded features. For example, in the sleep quality feature, there are three options: poor, average, and good. Each option corresponds to a vector [1, 0, 0], [0, 1, 0], and [0, 0, 1]. Fully connected neural networks have high computational complexity but are better at fitting input data, making them more suitable for data with fewer features, such as health information forms. Therefore, after one-hot encoding the health information form, a fully connected neural network is constructed to achieve physical constitution identification.
[0023] Then, the encoded features and continuous features from the user's physical characteristics need to be input into a system such as... Figure 2 The target fully connected model is shown. It should be noted that the target fully connected model is... Figure 3 This is a model that adds an entity embedding layer to the fully connected model shown.
[0024] Step S12: Entity embedding is performed on the encoded features using the target fully connected model to obtain target embedded features. Based on the target embedded features and the continuous features, the target fully connected model is used to predict the physical characteristics of the target hospitalized user to determine the target predicted physical condition of the target hospitalized user.
[0025] In this embodiment, entity embedding is performed on the encoded features using a target fully connected model to obtain the target embedded features. Specifically, entity embedding is performed on the encoded features using a target fully connected model based on a preset embedding layer weight matrix, the one-hot encoding dimension corresponding to the encoded features, and a preset embedding vector dimension to obtain the target embedded features. It should be noted that, as... Figure 4 The diagram shows the entity embedding layer structure. The input is a one-hot encoding of discrete features, and the output is a dense embedding vector. The formula for representing the processing structure of the entity embedding layer is shown below: ; Where Y represents the output embedding vector, and O represents the input one-hot encoded vector. W α×β This represents the weight matrix of the embedding layer. α This represents the dimension of the one-hot encoding. β Indicates the dimension of the embedding vector.
[0026] It should be noted that the entity embedding layer needs to set the dimension of the embedding vector, and the setting should be done according to the following formula: ; Taking a real-world digestive system abnormality as an example, it includes 43 feature values such as rectal bleeding, constipation, and diarrhea. Therefore, this feature is one-hot encoded as a 43-dimensional vector, i.e., O in the formula. The corresponding value is... α The value is 43. Set according to Equation 5.2. β The value is 10. The network determines its parameter matrix after learning. W α×β Finally, the 43-dimensional vector was reduced to 10 dimensions. The embedding vectors learned the associations between 43 feature values, including rectal bleeding, constipation, and diarrhea. Constipation and rectal bleeding are more likely to occur simultaneously in clinical practice, indicating a stronger correlation, and their embedding vectors are closer together. However, constipation and diarrhea generally do not occur simultaneously, indicating a weaker correlation, and their embedding vectors are farther apart. The entity embedding layer dimensions for the 26 discrete features were calculated based on the representation formula of the entity embedding layer processing structure. The feature values contained in each feature are shown in Table 1.
[0027] Table 1 Discrete Characteristics of Health Information Table ; In this way, by quantifying discrete text features through one-hot encoding and normalizing continuous numerical features, combined with the dimensionality reduction and semantic mining functions of entity embedding, a processing architecture adapted to the complex health data of hospitalized patients is constructed. Compared with existing technologies, it can make fuller use of the value of multiple types of data and improve the system's adaptability and processing efficiency for diverse health information.
[0028] Furthermore, continuous features need to be normalized to obtain normalized features. These normalized features are then concatenated with the target embedded features to obtain concatenated features. These concatenated features are then integrated using a pre-defined fully connected layer, and the integrated features are normalized to obtain the predicted probabilities of each predicted physical condition for the target hospitalized user. Specifically, such as... Figure 2 The target fully connected model shown has the following structure: after processing through the entity embedding layer to obtain the target embedded features, it needs to be concatenated with the normalized continuous features, then passed through a fully connected layer with 500 nodes, followed by a fully connected layer with 250 nodes, and finally through a Softmax layer to output the probabilities of balanced and non-balanced constitutions. The activation function used in the model is also a linear rectified function. It should be noted that the predicted probabilities of nine constitutions can be obtained, namely balanced constitution, qi deficiency constitution, yang deficiency constitution, yin deficiency constitution, phlegm-dampness constitution, damp-heat constitution, blood stasis constitution, qi stagnation constitution, and special constitution. The constitution with the highest probability is selected as the target predicted constitution for the hospitalized user.
[0029] In this way, by customizing a TCM constitution identification questionnaire containing 33 questions of various types, combining entity embedding model to mine semantic associations between discrete text features, and optimizing the fully connected network architecture to achieve efficient fusion of discrete and continuous features, the nine major TCM constitutions can be accurately identified. This solves the problems of insufficient feature expression and ambiguous constitution classification in existing technologies, and provides a scientific basis for dietary recommendations based on constitution.
[0030] Step S13: Based on the first food rating data of the target hospitalized user and the second food rating data of the target hospitalized user's target neighboring users, determine the target predicted rating of the target hospitalized user for each preset food, determine the food similarity between each preset food based on the current food collection data of each hospitalized user, and determine the predicted food preference value of the target hospitalized user for the target food based on the food similarity.
[0031] In this embodiment, a dual collaborative filtering recommendation algorithm is used to predict the target hospitalized users' preferences for items. It's important to note that weighting the user-based and item-based collaborative filtering recommendations is necessary to avoid the cold start problem caused by a single recommendation algorithm. Successful collaborative filtering requires historical user behavior data. If the system already has user favorites, ratings, or other behavioral records, the similarity between users or items can be calculated based on this historical data. The calculated similarity then yields the nearest neighbor dataset for each user or item. Finally, the user or item ratings from the nearest neighbor set are used to calculate the target user's rating for the food, and recommendations are made based on these ratings. Therefore, a hybrid recommendation strategy is adopted, combining user-based and item-based collaborative filtering algorithms.
[0032] For the user-based collaborative filtering algorithm in the dual collaborative filtering recommendation algorithm, it is necessary to collect the first food rating data of the target hospitalized user, and then collect the second food rating data of a predetermined number of target neighboring users through a preset bubble sort algorithm. It should be noted that the preset bubble sort algorithm is a bubble sorting algorithm, which selects the top 20 users as the nearest neighbor set of the target hospitalized user, i.e., the target neighboring users. Furthermore, it is necessary to calculate the rating similarity between the target hospitalized user and the target neighboring users based on the first and second food rating data. It should be noted that the calculation of the rating similarity between the target hospitalized user and the target neighboring users requires the use of the cosine similarity formula, which is expressed as follows: ; Here, A and B represent the rating vectors of two users for food.
[0033] After obtaining the rating similarity, it is necessary to determine the target predicted ratings for each preset food item by the target hospitalized user based on the rating similarity and the first food rating data. It should be noted that the target predicted ratings for each preset food item by the target hospitalized user need to be calculated using the predicted rating calculation formula, which is shown below: ; in, n Represents the nearest neighbor set. v This represents a user in the nearest neighbor set. sim ( u , v ) represents user u With users v Similarity between them r v,i For users v food i The rating.
[0034] Furthermore, for the food-based collaborative filtering algorithm in the dual collaborative filtering recommendation algorithm, it is necessary to collect the food collection data of each current hospitalized user and determine the number of users who have collected each preset food item based on the food collection data. The similarity between the preset foods is then determined based on the number of users who have collected them. Specifically, the Jaccard coefficient is used to calculate the physical detection similarity. Jaccard is used to compare the similarity and differences between a finite set of samples. The larger the Jaccard coefficient value, the higher the sample similarity. Its formula is as follows: ; The numerator represents the number of users who simultaneously collect food A and food B; the denominator represents the total number of users who collect either food A or food B.
[0035] Furthermore, it is necessary to determine the target food collection set of the target inpatient user and to determine several similarities between the target food and various target food collections in the target food collection. The sum of these similarities will be used as the predicted food preference value for the target inpatient user. It should be noted that the predicted food preference value for the target food needs to be calculated using a pre-defined preference calculation formula. The formula is as follows: ; in, n For users u A collection of food items, sim ( i , j ) indicates food i With food j The similarity value of the food. This formula represents the similarity value of the food. i The sum of similarities to all foods in the user's favorite collection.
[0036] In this way, by using a dual collaborative filtering weighted hybrid strategy, the user collaborative filtering algorithm based on cosine similarity is adapted to the food rating data, and the food collaborative filtering algorithm based on the Jaccard coefficient is adapted to the collection data, which effectively alleviates the cold start problem and data sparsity problem of a single algorithm.
[0037] Step S14: Generate a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value.
[0038] In this embodiment, a target food recommendation list needs to be generated. It should be noted that three methods are used for recommendation in this embodiment: one is related to the predicted user's physical condition, and the other two are not related to the user's physical condition.
[0039] First, generating a food recommendation list unrelated to the user's physical condition requires determining the target hospitalized user's current login status on the target medical client. If the login status is not logged in, several target ratings corresponding to a preset recommendation quantity threshold are selected from the target predicted ratings based on a preset rating order, and the first target recommended foods corresponding to these target ratings are determined. The preset rating order is from highest to lowest rating value. Second target recommended foods corresponding to a preset recommendation quantity threshold are selected from each preset food based on a preset collection quantity order. The preset collection quantity order is from highest to lowest collection quantity. Foods already rated and collected by the target hospitalized user are removed from the first and second target recommended foods to generate the first food recommendation list. It should be noted that this recommendation method is a popular recommendation, that is, recommending foods with high ratings and many collections, while filtering out foods already rated and collected by the currently logged-in user.
[0040] In another scenario, if the user is logged in, the first and second target food recommendations are weighted and mixed based on preset weights, and a second food recommendation list is generated based on the mixed result. That is, if the user is already logged in, a user-based collaborative filtering recommendation algorithm (food rating data) and an item-based collaborative filtering recommendation algorithm (food collection data) are used for weighted average recommendations. If the weighted average recommendation yields no results (due to cold start and data sparsity), popular recommendations are used, recommending foods with high ratings and many collections, while filtering out foods already rated and collected by the currently logged-in user. This recommendation method is what we call "Recommendations for You."
[0041] The recommendation method related to the predicted user constitution is as follows: Identify foods not recommended corresponding to the target predicted constitution, and remove these foods from the second food recommendation list to obtain a target food recommendation list corresponding to the target predicted constitution. It should be noted that the recommendation method related to the predicted user constitution is also known as health recommendation. The recommendations are based on the second food recommendation list, filtering out foods that do not match the user's constitution from the popular recommendation set; if the average weighted mixed recommendation yields no results, popular recommendations are used, recommending foods with high ratings and many favorites, while simultaneously filtering out foods already rated and favorited by the currently logged-in user.
[0042] This approach integrates constitution identification results with the dietary recommendation process, filtering out foods that do not suit the user's constitution. It addresses the previous shortcomings of disconnecting constitution identification with dietary recommendations, ensuring that the recommended plans meet both personalized needs and the clinical rehabilitation and health management needs of hospitalized patients, thereby reducing the risk of inappropriate diet affecting rehabilitation.
[0043] In this embodiment, discrete features of the target hospitalized user can be one-hot encoded, and the resulting encoded features and the user's continuous features are input into a fully connected model to perform entity embedding on the encoded features. Based on the obtained target embedded features and continuous features, the target predicted constitution of the user is predicted. Based on the food rating data of the user and neighboring users, the predicted rating of the user for each preset food is predicted, and the food similarity between each preset food is determined according to the food collection data of current hospitalized users. Based on the similarity, the user's predicted preference value for the target food is determined. Based on the predicted rating and the predicted preference value, a target food recommendation list corresponding to the target predicted constitution is generated. In this way, the constitution identification results can be combined with the dietary recommendation process, so that the recommendation scheme can meet both personalized needs and the clinical rehabilitation and health management needs of hospitalized patients, reducing the risk of rehabilitation being affected by improper diet.
[0044] As a preferred embodiment, this embodiment provides a detailed explanation of how to train the initial fully connected model to obtain the target fully connected model: During the model training phase, four parameters need to be tuned sequentially: the number of iterations, the loss function, the learning rate optimizer, and the batch size. The default loss function is cross-entropy, the default learning rate optimizer is Adam, the default batch size is 20, and the initial learning rate is 0.01. First, the number of model iterations is determined. The changes in loss during training are recorded on a training set of 1970 examples and a validation set of 197 examples, and the model learning curve is plotted. When the loss on the validation set tends to plateau, it indicates that the model has converged, and the number of iterations at this point is selected as the number of iterations for network training. Figure 5 The figure shows the variation curves of the entity embedding model loss. The light blue curve represents the change of the training set loss with the number of iterations, the light green curve represents the change of the validation set loss with the number of iterations, the dark blue curve represents the fitted curve of the training set loss, and the dark green curve represents the fitted curve of the validation set loss. As can be seen from the figure, when the number of iterations is 350, the training set and validation set losses tend to stabilize. Therefore, the number of iterations for the entity embedding model is fixed at 350, and other hyperparameters are further tuned.
[0045] Furthermore, it is necessary to discuss the model's performance under different loss functions. Hinge loss, cross-entropy loss, and KL (Kullback-Leibler Divergence) are the three most commonly used loss functions in binary classification tasks, so they were chosen for experiments. Table 2 shows the performance of the entity embedding model on the validation set under the three different loss functions. The table shows that cross-entropy loss achieves the best results in accuracy, sensitivity, and AUC (Area Under Curve). Therefore, the model loss function was fixed at cross-entropy, and other hyperparameters were further tuned.
[0046] Table 2. Classification performance of the model under different loss functions ; Next, we need to discuss the model's performance under different learning rate optimizers. With an initial learning rate of 0.01, we compared three common learning rate optimizers: Adam, SGD, and Adadelta. As shown in Table 3, the entity embedding model exhibited the highest accuracy, sensitivity, and AUC value under the Adam optimizer, but the model showed the best specificity under the Adadelta optimizer. After comprehensive comparison, we fixed the learning rate optimizer for the model as Adam and continued to fine-tune other hyperparameters.
[0047] Table 3. Classification performance of entity embedding models under different learning rate optimizers ; Finally, a grid search method was used to determine the number of images used to update weights during mini-batch gradient descent, i.e., the batch size. The search range for the batch size was set to [20, 40, 60, 80, 100]. Table 4 shows the classification metrics of the entity embedding model under different batch sizes. As can be seen from Table 4, the model performs best in three metrics when the batch size is 40. Therefore, the batch size of the model was fixed at 40.
[0048] Table 4. Classification performance of the model under different batch sizes ; Ultimately, the model achieved optimal performance with 350 iterations, cross-entropy as the loss function, Adam as the learning rate optimizer, and a batch size of 40. Using a similar strategy, the ordinary fully connected model achieved optimal performance with 250 iterations, cross-entropy as the loss function, Adadelta as the learning rate optimizer, and a batch size of 60. After determining the optimal hyperparameters using cross-validation, the training and validation sets were merged to train the model, resulting in a constitution identification model based on a health information table.
[0049] See Figure 6 As shown, this embodiment of the invention discloses a diet recommendation device for hospitalized patients, applied to a target medical client, comprising: The feature encoding module 11 is used to perform one-hot encoding on the discrete features in the collected user physical characteristics of the target hospitalized users to obtain encoded features, and input the encoded features and the continuous features in the user physical characteristics into the target fully connected model. The physical fitness prediction module 12 is used to perform entity embedding on the encoded features through the target fully connected model to obtain target embedded features, and to predict the physical fitness features of the target hospitalized user based on the target embedded features and the continuous features through the target fully connected model to determine the target predicted physical fitness of the target hospitalized user. The diet data determination module 13 is used to determine the target predicted score of the target hospitalized user for each preset food based on the first food score data of the target hospitalized user and the second food score data of the target hospitalized user's target neighboring users, and to determine the food similarity between each preset food based on the current food collection data of each hospitalized user, and to determine the predicted food preference value of the target hospitalized user for the target food based on the food similarity. The recommendation list generation module 14 is used to generate a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value.
[0050] In this embodiment, discrete features of the target hospitalized user can be one-hot encoded, and the resulting encoded features and the user's continuous features are input into a fully connected model to perform entity embedding on the encoded features. Based on the obtained target embedded features and continuous features, the target predicted constitution of the user is predicted. Based on the food rating data of the user and neighboring users, the predicted rating of the user for each preset food is predicted, and the food similarity between each preset food is determined according to the food collection data of current hospitalized users. Based on the similarity, the user's predicted preference value for the target food is determined. Based on the predicted rating and the predicted preference value, a target food recommendation list corresponding to the target predicted constitution is generated. In this way, the constitution identification results can be combined with the dietary recommendation process, so that the recommendation scheme can meet both personalized needs and the clinical rehabilitation and health management needs of hospitalized patients, reducing the risk of rehabilitation being affected by improper diet.
[0051] In some embodiments, the feature encoding module 11 may specifically include: The one-hot encoding unit is used to collect the physical characteristics of target hospitalized users through a preset physical fitness identification questionnaire, and to perform one-hot encoding on the discrete features in the physical fitness characteristics to convert the discrete features into corresponding one-hot encoded vectors, and to use the one-hot encoded vectors as the encoded features corresponding to the discrete features.
[0052] In some embodiments, the body composition prediction module 12 may specifically include: The entity embedding unit is used to perform entity embedding on the encoded features based on the preset embedding layer weight matrix, the one-hot encoding dimension corresponding to the encoded features, and the preset embedding vector dimension through the target fully connected model to obtain the target embedded features; The feature concatenation unit is used to normalize the continuous features to obtain normalized features, and to concatenate the normalized features with the target embedded features to obtain concatenated features. The probability prediction unit is used to integrate the spliced features through a preset fully connected layer and normalize the integrated features to obtain the predicted probability of each predicted physical condition of the target hospitalized user. A body composition prediction unit is used to determine the target predicted body composition of the target hospitalized user based on the predicted probability.
[0053] In some embodiments, the diet data determination module 13 may specifically include: The data collection unit is used to collect the first food rating data of the target hospitalized user and to collect the second food rating data of a preset number of target neighboring users corresponding to the target hospitalized user through a preset bubble algorithm. A similarity calculation unit is used to calculate the rating similarity between the target hospitalized user and the target adjacent user based on the first food rating data and the second food rating data, respectively. A rating prediction unit is used to determine the target predicted rating of the target hospitalized user for each preset food based on the rating similarity and the first food rating data.
[0054] In some embodiments, the diet data determination module 13 may specifically include: The similarity determination unit is used to collect the food collection data of each current hospitalized user, and determine the number of users' collections of each preset food based on the food collection data, so as to determine the food similarity between each preset food based on the number of users' collections. The prediction value calculation unit is used to determine the target food collection set of the target hospitalized user, and to determine several similarities between the target food and various target food collections in the target food collection set, so as to use the sum of the several similarities as the predicted food preference value of the target hospitalized user for the target food.
[0055] In some embodiments, the dietary recommendation device for hospitalized patients may further include: A login status determination unit is used to determine the current login status of the target inpatient user on the target medical client; The first recommended food determination unit is used to, if the login status is not logged in, filter out several target scores corresponding to a preset recommendation quantity threshold from the target predicted scores based on a preset rating order, and determine the first target recommended food corresponding to the several target scores; the preset rating order is the order of rating values from high to low; The first recommended food determination unit is used to select a second target recommended food corresponding to the preset recommended quantity threshold from the preset foods according to the preset collection quantity order; the preset collection quantity order is from high to low collection quantity. The first list generation unit is used to remove the foods that the target hospitalized user has rated and saved from the first target recommended foods and the second target recommended foods, so as to generate a first food recommendation list; The second list generation unit is used to, if the login status is logged in, perform a weighted mixture of the first target recommended food and the second target recommended food based on a preset weight, and generate a second food recommendation list based on the obtained mixture result.
[0056] In some embodiments, the recommendation list generation module 14 may specifically include: The third list generation unit is used to determine the unrecommended foods corresponding to the target predicted physique, and remove the unrecommended foods from the second food recommendation list to obtain the target food recommendation list corresponding to the target predicted physique.
[0057] Furthermore, embodiments of this application also disclose an electronic device, Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0058] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the dietary recommendation method for hospitalized patients disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be a computer.
[0059] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0060] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0061] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs capable of performing the dietary recommendation method for hospitalized patients executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0062] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed method for providing dietary recommendations to hospitalized patients. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0063] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0064] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0065] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0066] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0067] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method of recommending a diet for a hospitalized patient, characterized by, Applied to target medical clients, including: Discrete features in the collected physical characteristics of target hospitalized users are one-hot encoded to obtain encoded features, and the encoded features and continuous features in the physical characteristics of users are input into the target fully connected model. The encoded features are embedded into entities using the target fully connected model to obtain target embedded features. Based on the target embedded features and the continuous features, the target fully connected model is used to predict the physical characteristics of the target hospitalized user to determine the target predicted physical condition of the target hospitalized user. Based on the first food rating data of the target hospitalized user and the second food rating data of the target hospitalized user's target neighboring users, the target predicted rating of the target hospitalized user for each preset food is determined, and the food similarity between each preset food is determined based on the current food collection data of each hospitalized user, and the food preference prediction value of the target hospitalized user for the target food is determined based on the food similarity. Based on the target prediction score and the food preference prediction value, a target food recommendation list corresponding to the target predicted physique is generated.
2. The dietary recommendation method for hospitalized patients according to claim 1, characterized in that, The process of performing one-hot encoding on the discrete features of the collected physical characteristics of target hospitalized users to obtain encoded features includes: The physical characteristics of target hospitalized users are collected through a pre-set physical fitness identification questionnaire. The discrete features in the physical fitness characteristics are then one-hot encoded to transform the discrete features into corresponding one-hot encoded vectors. These one-hot encoded vectors are then used as encoded features corresponding to the discrete features.
3. The dietary recommendation method for hospitalized patients according to claim 1, characterized in that, The step of embedding entities into the encoded features using the target fully connected model to obtain target embedded features, and then using the target fully connected model to predict the physical characteristics of the target hospitalized user based on the target embedded features and the continuous features, to determine the target predicted physical condition of the target hospitalized user, includes: The target fully connected model performs entity embedding on the encoded features based on the preset embedding layer weight matrix, the one-hot encoding dimension corresponding to the encoded features, and the preset embedding vector dimension to obtain the target embedded features; The continuous features are normalized to obtain normalized features, and the normalized features are concatenated with the target embedded features to obtain concatenated features. The spliced features are integrated by a preset fully connected layer, and the integrated features are normalized to obtain the predicted probability of each predicted physical condition for the target hospitalized user. The target predicted physical condition of the target hospitalized patient is determined based on the predicted probability.
4. The dietary recommendation method for hospitalized patients according to claim 1, characterized in that, The determination of the target predicted rating for each preset food based on the first food rating data of the target hospitalized user and the second food rating data of the target hospitalized user's target neighboring users includes: Collect the first food rating data of the target hospitalized patient, and collect the second food rating data of a preset number of target neighboring patients corresponding to the target hospitalized patient through a preset bubble algorithm; Calculate the rating similarity between the target hospitalized user and the target adjacent user based on the first food rating data and the second food rating data, respectively. Based on the rating similarity and the first food rating data, the target predicted rating of the target hospitalized user for each preset food is determined.
5. The dietary recommendation method for hospitalized patients according to claim 1, characterized in that, The step of determining the food similarity between preset foods based on the current food collection data of each hospitalized patient, and determining the predicted food preference value for the target food for the target hospitalized patient based on the food similarity, includes: Collect food collection data of each current hospitalized patient, and determine the number of users who have collected each preset food based on the food collection data, so as to determine the food similarity between each preset food based on the number of users who have collected it; The target hospitalized user's target food collection set is determined, and several similarities are determined between the target food and various target food collections in the target food collection set. The sum of the several similarities is used as the predicted food preference value of the target hospitalized user for the target food.
6. The method for providing dietary recommendations for hospitalized patients according to any one of claims 1 to 5, characterized in that, Before generating the target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value, the method further includes: Determine the current login status of the target inpatient user on the target medical client; If the login status is not logged in, then based on the preset rating order, several target ratings corresponding to the preset recommendation quantity threshold are selected from the target predicted ratings, and the first target recommended food corresponding to the several target ratings is determined; the preset rating order is the order of rating values from high to low; Based on a preset order of collection volume, a second target recommended food corresponding to a preset recommended quantity threshold is selected from the preset foods; the preset order of collection volume is from high to low. Remove the foods that the target hospitalized user has rated and saved from the first target recommended foods and the second target recommended foods to generate a first food recommendation list; If the login status is "logged in", then the first target recommended food and the second target recommended food are weighted and mixed based on preset weights, and a second food recommendation list is generated based on the mixed result.
7. The dietary recommendation method for hospitalized patients according to claim 6, characterized in that, The process of generating a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value includes: Identify the unrecommended foods corresponding to the target predicted physique, and remove the unrecommended foods from the second food recommendation list to obtain the target food recommendation list corresponding to the target predicted physique.
8. A dietary recommendation device for hospitalized patients, characterized in that, Applied to target medical clients, including: The feature encoding module is used to perform one-hot encoding on the discrete features in the collected physical characteristics of the target hospitalized users to obtain encoded features, and input the encoded features and the continuous features in the physical characteristics of the users into the target fully connected model. The physical fitness prediction module is used to embed entities into the encoded features through the target fully connected model to obtain target embedded features, and to predict the physical fitness features of the target hospitalized user based on the target embedded features and the continuous features through the target fully connected model to determine the target predicted physical fitness of the target hospitalized user. The diet data determination module is used to determine the target predicted score of the target hospitalized user for each preset food based on the first food score data of the target hospitalized user and the second food score data of the target hospitalized user's target neighboring users, and to determine the food similarity between each preset food based on the current food collection data of each hospitalized user, and to determine the predicted food preference value of the target hospitalized user for the target food based on the food similarity. The recommendation list generation module is used to generate a target food recommendation list corresponding to the target predicted physique based on the target prediction score and the food preference prediction value.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the dietary recommendation method for hospitalized patients as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the dietary recommendation method for hospitalized patients as described in any one of claims 1 to 7.