Personalized Diet Recommendation System Using Machine Learning

DOI : 10.17577/IJERTV13IS020125
Download Full-Text PDF Cite this Publication

Text Only Version


Personalized Diet Recommendation System Using Machine Learning

Asst Prof. Ms. D. Navya Narayana Kumari, T. Praveen Satya,

B. Manikanta, A. Phani Chandana, Y. L.S Aditya

Electronics and Communication Engineering Godavari Institute of Engineering and Technology (A)

Abstract -“Personalized Diet Recommendation System”, using machine learning, focuses primarily on individual nutritional advice and overall well-being. This project involves building a machine learning model for personalized health and nutrition recommendations based on various input parameters. The model takes into account factors such as age, gender, daily meals, exercise intensity and weight goals. It then assesses the health of the user, determining whether he is in good shape or may be struggling with obesity.

After the analysis, the system will generate its own diet plans for breakfast, lunch and dinner. These plans include detailed nutritional information for each meal, including preparation instructions. The user is encouraged to select preferred foods from various sections for each meal. The system estimates the total nutritional intake and displays it in a pie chart for a comprehensive overview of the person. In our project, the output is designed based on physical characteristics

, user preferences and body mass index (BMI).

Keywords: Nearest Neighbor Algorithm,FastAPI

,Streamlit, Standard Scaler, Cosine Similarity.


    People today struggle with a variety of health issues, including mental health issues, poor diet and fitness issues. Numerous studies have shown that a poor diet is a major contributor to a wide range of health problems. A WHO study found that an inadequate and unbalanced diet is responsible for approximately 9% of heart attack deaths, 11% of heart disease (ischemia) deaths and 14% of gastrointestinal cancer deaths worldwide, which are attributed to. In addition, approximately 250 million children suffer

    from vitamin A deficiency, 200 million from iron deficiency (anemia) and 700 million from iodine deficiency. A food recommendation system is a tool that helps people make healthy food choices. Dietary recommendation systems analyze dietary preferences, nutritional needs and other dietary factors to provide personalized recommendations for healthier eating. Based on the user’s age, height, and weight, BMI calculates weight categories that include underweight, healthy, overweight, and obese. This project will help users with daily diet recommendations along with BMI ranges, healthy food choices, eating behaviors and health issues.


    Diet recommendation system using machine learning [1]

    In this paper, the authors used new technologies such as artificial intelligence and machine learning techniques to implement the project. They used these technologies to develop software for those looking for advice on their diet and healthy living. If you want to live a healthy and fit life, nutritional counseling is increasingly important.

    Realization of an effective patient diet recommen dation system with the help of IoMT using machine learning [2]

    Celestine Iwendi et al. (2020) explore the data collection potential of their system. This research framework targets machine and deep learning algorithms such as Naive Bayes, Logistic Regression, Multilayer Perceptron (MLP), Gated Recurrent Units (GRU), Recurrent Neural Networks (RNN) and Long Short-Term Memory (LSTM). as they apply to IoMT data. For consideration in the clinical data set, 30 pieces of information about 30 people with 13 most important pieces of information about different diseases as well as 1000 things were collected from the Internet and hospitals. There are eight functions in the product area. Before applying deep learning and machine learning techniques, the properties of this IoMT data were explored and further coded.

    A nutritional diet recommendation system using user interest [3]

    Butti Gouthami and Malige Gangappa (2020) The USDA Nutrition Data Set will be used to determine a user’s recommended diet. A set of grocery store information that takes into account the user’s preferred food intake. The USDA database contains nutritional information for every food. The USDA ID is used as the base value for input values per 100 grams. As they will ultimately be used to estimate the suggested diet, it is necessary to provide the data needed to calculate the BMI (Body Mass Index).

    A food recommendation system based on nutritional information and user preferences [4]

    Rachel Yera Toledoy et al. designed a food recommendation system that takes into account user preferences and nutritional data. It includes an optimization-based phase to generate a daily meal plan that aims to recommend foods that the user highly prefers, has not consumed recently, and that will satisfy his/her daily nutritional requirements. A case study is developed to test the performance of the food. recommender system. The user’s recommended meal plan took into account their preferences. This tool preserves both user preferences and nutritional information

    Vitamin Deficiency and Food Recommender System Using Machine Learning [5]

    Naga Lakshmi et al. (2022) proposed a client- specific food recommendation system based on elements such as food preferences, food availability, medical information, disease information, caloric information for a food, personal information and activity level of each individual for a given food database. The most important task in the implementation is to suggest a certain food from the food database based on certain constraints such as the probability of that food, its availability, allergies to that food, and its nutritional components such as protein, carbohydrates, and fat. in that food. This tip helps in choosing foods from the database so that nutritional deficiencies do not manifest themselves in the near future and everyone is provided with an appropriate diet plan while maintaining their daily calorie intake.

    Food recommendation system using cluster analysis for diabetic patients [6]

    Food Recommendation System (FRS) is designed for diabetic patients who used K-mean clustering and Self-Organizing Map for food cluster analysis. The proposed system recommends substituted foods according to nutritional values and food parameters. However, the FRS does not adequately address the issue of disease level, as the level of diabetes may vary hourly in different patient situations, and food recommendations may vary accordingly.

    Overview of recommendation techniques and their applications in healthcare [7]

    Wenbin Yue et al state that the aim of this work is to provide a comprehensive review of traditional referral methodologies and applications in healthcare. Content-based recommendation (also known as CF recommendation), collaborative filtering (CF recommendation), and hybrid recommendation are the three main recommendation methodologies discussed. Following this, we provide an overview of five high- level health-related application scenarios, including but not limited to dietary advice, lifestyle advice, training advice, patient-physician decision making, and disease prediction. Finally, some of the most critical challenges facing this new and emerging

    profession are recognized, along with compelling reasons.

    Recommender systems in the healthcare domain [8] Thi Ngoc Trang Tran et al. (2021) show that their method can be used to present a comprehensive review of healthcare recommender systems research: In addition, our survey of past important outlines acknowledges that it provides insights into proposed circumstances and approaches. Dietary recommendations, medication ideas, health forecasts, service recommendations, and healthcare professional recommendations are part of this type of proposal. They also give students examples from real situations to help them fully understand the referral system


    Several works have been proposed for various diet and food related recommendation systems. These systems are used for food recommendations, menu recommendations, dietary recommendations, disease-specific health recommendations, and recipe recommendations. Most of these recommendation systems obtain user preferences from various sources such as user ratings. Food Recommendation System (FRS) [1] is designed for diabetic patients, which used K-means clustering and self-organizing map for food cluster analysis. The proposed system recommends substituted foods according to nutritional values and food parameters. However, the FRS does not adequately address the issue of disease level, as the level of diabetes may vary hourly in different patient situations and food recommendations may vary accordingly. Brands and latent factor are used for Android based food recommendation system [2]. The system will recommend a personalized recipe to the user based on the brands and ratings listed in the user preferences. The proposed system used latent symptom vectors and matrix factorization in its algorithm. Prediction accuracy is achieved by using brands that closely match recommendations to user preferences. However, the authors do not consider nutrition in order to balance the user’s diet according to his needs.

    A content-based food recommendation system is proposed [3], which will recommend food recipes according to preferences already given by the user. The user’s preferred recipes are divided into ingredients, which are assigned ratings based on saved user preferences. In the case of disease- specific food recommendations, systems recommend different foods to patients without knowing the level of the disease, which may vary in different cases and cause serious consequences for patients. Similarly, in the case of food recommendations for a balanced diet, nutritional factors that are very important for food recommendations and a balanced diet are ignored.


    In contrast, the Personalized Diet Recommender System uses a content-based filtering approach with a cosine similarity-based nearest neighbor model. This specific algorithm takes into account the nutritional content of recipes, making it more suitable for recommending meals tailored to users’ dietary preferences and weight management goals. Using the Nearest Neighbors model increases the accuracy and relevance of recommendations by finding recipes with similar nutritional profiles.

    Data Exploring & preprocessing

    Content based filtering

    Backend API

    User interface input

    Nearest neighbor model

    Web application integration

    Recommendation engine API

    Fig (a) Block diagram for the proposed system

    In our project we are not only showing the food recommendation but also giving proper diet for 4 meals in a day starting from breakfast, lunch, snacks and dinner. Not only this we are also showing the total macronutrients and micronutrients involved in that food and also helps the user to prepare that recipe by showing the process step by step and ingredients used in that. This way user can get to know what food he/she can eat by knowing how much healthy as well as to maintain proper diet.



The primary goal of the “machine learning personalized diet recommendation system” is to use machine learning algorithms and nutritional data to

  1. Data exploration

    Using techniques like Pandas and NumPy, they are used to understand and process the dataset, deal with missing values, scale features, and select core attributes for the recommendation model.

  2. The recommendation engine

    It implements a content-based filtering approach and trains a Nearest Neighbors model with cosine similarity to find recipes with similar nutritional profiles.A scalable pipeline is created to process user requests and provide real-time recommendations.

  3. The user interface

    The user interface was developed using Streamlit, which is designed to be user-friendly and allow users to enter personal information, dietary preferences and weight loss goals. It provides users with an interactive and visually appealing platform to receive dietary recommendations and explore recipe options


  4. Web application Integration

    FastAPI backend integration ensures smooth communication and responsiveness between frontend and backend. Output formatting focuses on presenting recommendations in an easy-to- understand and visually appealing way, providing nutritional details, recipe ingredients, directions, and cooking/prep times.

  5. Model development
  1. Content-based recommendation engine is a type

    of recommendation system that uses the characteristics or content of an item to recommend similar items to users. It works by analyzing the content of items, such as text,

    Data Acquisition

    create meal plans tailored to individual preferences, taking into

    images, or audio, and identifying patterns or

    features that are associated with certain items.

    account factors such as age, gender, activity level and weight loss goals. The scope of the project includes the development of a complex system that seamlessly integrates data collection, processing, recommendation generation and user interface components.

    2.Data acquisition

    This involves using a dataset from to obtain comprehensive nutritional information on various recipes and processing it to extract relevant properties, including macronutrients and other dietary components.

    These patterns or features are then used to

    compare items and recommend similar ones to users.

  2. Algorithm used

The recommender is built using the Nearest Neighbors alogrithm, which is an unsupervised user implementation of neighbor search. It acts as a unified interface for three different nearest neighbor algorithms: BallTree, KDTree, and a brute force algorithm based on routines in sklearn.metrics.pairwise. For our case, we used the brute force algorithm using cosine similarity due to its fast computation for small datasets.

The Nearest Neighbors algorithm, a basic machine learning technique, works on the principle of similarity. Its goal is to find the most similar data points (neighbors) to a given query point based on the selected distance metric. Essentially, it locates the points in the dataset that are closest to the query point in terms of feature space.

How Nearest Neighbors Work:

  1. Distance calculation: The algorithm calculates the distance between the query point and all other points in the data set. Common distance metrics include Euclidean distance, Manhattan distance, and cosine similarity, among others.
  2. Neighbor selection: After calculating the distances, the algorithm selects the nearest neighbors to the query point based on the selected distance metric. The value of k, known as the number of neighbors, is a hyperparameter that must be specified in advance.
  3. Prediction/Recommendation: For classification tasks, the algorithm assigns the query point to the class most often represented among its k nearest neighbors (k-NN classification). For regression tasks, it calculates a prediction based on the average or weighted average of the k-nearest-neighbor target values (k-NN regression).
    1. RESULTS

      Fig (1): Collecting input from the user.

      Fig (2): Displays the Body Mass Index (BMI) and calories calculator

      Fig (3): Choosing the diet based on the user interest

      Fig (4): isplays the ingredients in the selected recipe and process for the preparation of food

      Fig (5): Shows the calories in a bar chart

      Fig (6): Shows the calories and nutritional content in the selected recipes


      In the ever-evolving information technology landscape, the integration of cutting-edge technologies such as machine learning and artificial intelligence has become a tool for revolution in various industries, including health and wellness. Our project harnesses the power of these improvements to address the pressing need for personalized nutrition advice and support in today’s fast-paced world. Using machine learning algorithms and sophisticated data analysis techniques, we have developed a user-centric website that empowers individuals to take control of their eating habits and embark on a journey to improved health and well-being. Recognizing the growing importance of nutrition counseling in maintaining a healthy lifestyle, our platform offers users personalized diet plans tailored to their unique preferences and nutritional needs. In conclusion, our project represents a key step forward in using technology to promote health and well-being among individuals. By harnessing the power of machine learning and artificial intelligence, we’ve developed a solution that not only responds to the growing demand for nutritional advice, but also empowers users to take proactive steps towards a healthier and happier life. As we continue to refine and expand our platform, we remain committed to supporting individuals on their journey to improved health and wellness through personalized dietary recommendations and support.

  1. Prerana Madhira, Harshini Kotapati, Batta Kavya, S. Mounasri Dietary Recommendation System Using Machine Learning
  2. Celestine Iwendi, Suleman Khan, Joseph Henry Anajemba, Ali Kashif Bashir, and Fazal Noor, Realizing an Efficient IoMT- Assisted Patient Diet Recommendation System through Machine Learning Model, IEEE Access, vol. 8,2020,pp.28462-28474, doi:10.1109/ACCESS


  1. Butti Gouthami and Malige Gangappa, A Nutrition recommendation system using user interest, International Journal of Advanced Research in Engineering and Technology (IJARET), Vol. 11, 2020, pp. 2910-2919, doi:10.34218/IJARET.11.12.2020.272.
  2. Rachel Yera Toledo, Ahmad A Alzahrani, and Luis Martinez, A food recommendation system considering nutritional information and user preferences, IEEE Access, vol. 7, 2019, pp.96695-96711,doi: 10.1109/ACCESS.92941


  3. N. Naga Lakshmi, M. Jagadeesh Reddy, K. Hari Krishna,S. Sindhuja Reddy, Vitamin and Food Recommender System Using Machine Learning, ISSN: 2321-9653; IC value: 45.98; SJImpact Factor: 7538 Volume 10 Issue V May 2022

    – Available at

  4. Phanich, M., Pholkul, P., & Phimoltares, S., Food recommendation system using clustering

    Analysis for diabetic patients,in Proc.of International Conference on Information science and Applications, pp.

    1-8, IEEE, April 2010. Article

  5. T. N. T. Tran, A. Felfernig, C. Trattner, and A. Holzinger, Healthcare Recommender Systems: State-of- the-Art and research issues, J. Intell. Inf. Syst., Vol. 57,

    No. 1, pp. 171201, 2021, doi: 10.1007/ s10844-020-00633-6.

  6. W. Yue, Z. Wang, J. Zhang, and X. Liu, A review of recommendation techniques and their applications in healthcare, IEEE/CAA J. Autom. Sin., St. 8, No. 4, pp. 701 717, 2021, doi: 10.1109/JAS.2021.100919.