0% found this document useful (0 votes)
20 views8 pages

Diet N Workout Recom

The study presents a personalized diet and workout recommendation system utilizing machine learning algorithms, specifically the Nearest Neighbors approach, to address the rising prevalence of obesity and chronic illnesses. By leveraging a dataset from Food.com, the system generates tailored dietary and exercise suggestions based on individual user data, including demographic information and health metrics. The methodology incorporates advanced data processing techniques and user feedback to evaluate the system's effectiveness in promoting healthy behaviors and improving health outcomes.

Uploaded by

nizsam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

Diet N Workout Recom

The study presents a personalized diet and workout recommendation system utilizing machine learning algorithms, specifically the Nearest Neighbors approach, to address the rising prevalence of obesity and chronic illnesses. By leveraging a dataset from Food.com, the system generates tailored dietary and exercise suggestions based on individual user data, including demographic information and health metrics. The methodology incorporates advanced data processing techniques and user feedback to evaluate the system's effectiveness in promoting healthy behaviors and improving health outcomes.

Uploaded by

nizsam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Journal of Nonlinear Analysis and Optimization

Vol. 15, Issue. 1 : 2024


ISSN : 1906-9685

DIET AND WORKOUT RECOMMENDATION USING NEAREST NEIGHBORS

Dr. S. NagaMallik Raj, Associate Professor of Computer Science Department (CSE), Vignan’s
Institute of Information Technology, Vishakapatnam, India, [email protected]
Y.S.S.S.R.Prabhakar , Take Sai Manohar, Tadi Prem Kumar Naidu, Pilla Keerthi Priya,
Rajavarapu Tejaswini, Computer Science Department (CSE), Vignan’s Institute of Information
Technology, Vishakapatnam, India, [email protected]

ABSTRACT: The rising prevalence of obesity and chronic illnesses has sparked a growing interest
in personalized health and wellness solutions. Diet and exercise recommendation systems have
gained recognition as a valuable method for providing personalized suggestions to promoting healthy
behaviors and improving health outcomes. However, existing systems often overlook individual
differences and preferences, resulting in less-than-optimal recommendations. This study aims to
close this divide through the creation of a personalized diet and exercise recommendation system
that utilizes Streamlit for the user interface and the Nearest Neighbors machine learning algorithm.
To develop our recommendation system, we utilized the food.com recipes and reviews dataset,
which provided a wealth of information for our content-based recipe recommendations. This dataset
includes recipe and review data from Food.com, featuring over 500,000 recipes and a community-
inspired activity feed for users to share their reviews. It encompasses various features such as recipe
identifier, title, components, time required for preparation, duration of cooking, number of servings
cuisine, and nutrition information. We employed feature engineering techniques to predict a
recipe's cuisine based on its ingredients. Our methodology involves leveraging Scikit-learn's
machine-learning capabilities to analyze user data, including demographic information, dietary
habits, exercise history, and health metrics. By utilizing algorithms like Ball Tree, KD Tree, or k-
nearest neighbors, the system learns patterns from the data to generate personalized
recommendations. We evaluate the effectiveness of our proposed system through extensive
experimentation and user feedback. By comparing the system's recommendations with expert advice
or established guidelines, we can assess its accuracy and efficacy. Additionally, user satisfaction and
adherence to the recommendations serve as crucial metrics for evaluating the system's performance.
Keywords: Diet Recommendation, Machine Learning, Ball tree and KD Tree, Scikit-learn,
Personalized Healthcare.

1. INTRODUCTION
In recent years, the widespread occurrence of lifestyle-related conditions, including obesity, diabetes,
and heart-related ailments, has reached alarming levels globally. These conditions are often
attributed to unhealthy dietary habits and sedentary lifestyles. Consequently, there is a growing
demand for effective interventions that encourage nutritious dietary practices and consistent exercise
routines. Traditional approaches to diet and workout recommendations often rely on generic
guidelines that may not account for individual preferences, dietary restrictions, or fitness goals.
However, with the advancements in machine learning and data science, personalized
recommendation systems have surfaced as an encouraging answer to tackle this issue to address this
challenge. These systems leverage user-specific data, such as nutritional profiles, fitness levels, and
lifestyle preferences, to generate tailored recommendations for diet and exercise. In this study, we
introduce a unique method to personalized diet and workout recommendations using machine-
learning techniques. Our system integrates various components, including data preprocessing, feature
scaling, nearest neighbors, modelling, and pipeline construction, to deliver customized
recommendations customized to meet the individual preferences and needs of each user. At the heart
of our recommendation system lies in the utilization of a nearest neighbors algorithm, specifically
1545 JNAO Vol. 15, Issue. 1 : 202
tailored to handle nutritional and fitness data. By leveraging cosine similarity metrics and brute-
force algorithms, we can identify the most relevant recipes and workout routines that closely match
the user's input parameters. Moreover, our system incorporates scalable preprocessing techniques
and pipeline construction to ensure efficient processing of large datasets while maintaining the
integrity of the recommendations. One of the primary benefits of our method is its adaptability to
diverse user-profiles and dietary requirements. Whether an individual follows a specific dietary
regimen, such as veganism or gluten-free diet, or has unique fitness goals, our recommendation
system can accommodate these variations and provide tailored suggestions accordingly.
Furthermore, we extend our framework to encompass workout recommendations, leveraging the
capabilities of OpenAI's cutting-edge linguistic algorithms. By leveraging OpenAI's advanced
technology text generation capabilities, we allow users to obtain customized exercise plans and
fitness advice tailored to their fitness goals, experience level, and physical limitations. By leveraging
machine learning techniques and user-specific data, we strive to equip people with the knowledge to
make educated decisions regarding their diet and physical activity, thereby fostering enduring health
and well-being.

2. REVIEW OF LITERATURE
Recently, there has been an increasing focus on the creation of diet and workout recommendation
systems, particularly those that are personalized to individual needs. This interest has been fueled by
the potential of these systems to improve health outcomes, reduce the likelihood of long-term health
conditions along with aid in the management of specific health problems including diabetes,
cancer along with post-transplant weight gain. The use of deep learning algorithms and medical
datasets has been proposed as a method for developing personalized nutrition plans, and
researchers have been investigating the potential of these systems in various healthcare settings.
The study by Subramaniyaswamy et al. (2018) proposed a personalized nutritional suggestion
platform, guided by ontology, within an IoT-enabled healthcare framework [1], which utilizes deep
learning algorithms and medical datasets. This approach has the potential to provide personalized
nutrition plans, taking into account individual health conditions and dietary requirements. However,
investigations are required to confirm the efficacy and precision of these recommendations in real-
world settings. Furthermore, The research performed by Raggatt and colleagues in 2018 emphasized
the interaction regarding the effects of fitness inspiration on social media on health and well-being
[2]. This finding emphasizes the importance of considering social and behavioral factors in the
development of diet and workout recommendation systems. Subsequent studies ought to explore the
influence of social media and a and other behavioral influences on adopting and adhering to
personalized nutrition and exercise plans. In addition, there is a need for tailored diet and workout
recommendation systems for specific populations, such as American Indian patients and kidney
transplant recipients. For example, Burke et al. (2019) discussed the importance of nutrition for
American Indian athletes[3], and the study by Grgic and colleagues (2021) focused on sodium
bicarbonate and exercise performance in the context of kidney transplant recipients[4].
These findings highlight the necessity of recommendations that are sensitive to cultural nuances and
specific to conditions, aimed at meeting the distinct needs of different populations. Moreover, the
study by Schmitz and colleagues (2019) emphasized the potential regarding home-based exercise and
weight management programs for breast cancer survivors. This suggests the importance of regarding
exercise and nutritional guidance tailored to particular health conditions, such as breast cancer[5].
Future research should explore the optimal combination of exercise and dietary interventions for
different patient populations undergoing treatment or in posttreatment phases.
Furthermore, the study by Iwendi et al. (2020) an effective patient diet recommendation system
supported by IoMT (Internet of Medical Things), utilizing machine learning techniques models[6].
This technological approach holds promise for developing user-friendly and effective diet and
workout recommendation systems. However, investigation is required to evaluate the usability and
acceptance of these systems among patients and healthcare providers Freitas et al. (2017) discuss the
advantages associated with health, physical appearance, enhanced vitality and fitness, while also
considering obstacles like motivation, scheduling conflicts, financial limitations, and the easy
availability of unhealthy food options [7]. This highlights the importance of not only providing
1546 JNAO Vol. 15, Issue. 1 : 202
recommendations but also addressing the motivational and environmental factors that may hinder
individuals from following the recommendations effectively.
In conclusion, the literature on diet and workout recommendation systems has provided meaningful
perspectives on the potential of tailored dietary strategies, the impact of social and and behavioral
factors, and the importance of tailored recommendations for specific populations. Subsequent studies
ought to concentrate on verifying the precision and efficacy of these systems, exploring the impact of
social and behavioral influences, and developing culturally sensitive and condition specific
recommendations. Additionally investigation is required to evaluate the usability and acceptance of
technological methods in this domain. This will aid in creating efficient and intuitive systems for
promoting healthy dietary intake and regular physical activity.

3. METHODOLOGY
The project involves the development of a Diet Recommendation System utilizing a a content-centric
methodology to offer personalized dietary suggestions based on nutritional data and ingredients. It
integrates FastAPI, a high performance web framework, to facilitate efficient API creation, enabling
seamless interaction with users.
The backend, complemented by Pydantic models for data validation, employs scikit-learn for
preprocessing and nearest neighbors prediction. By leveraging these technologies, the system aims to
optimize health outcomes by promoting healthy eating habits through tailored recommendations.

4. DATA SET ATTRIBUTES


Data for this study was meticulously curated from the 'Food.com Recipes and Reviews' dataset from
Kaggle consists of two datasets: Recipes and Reviews. The Recipes dataset contains over 500,000
recipes from 312 categories, including general meals and specific nutritional content. Each recipe
has 28 rows with various details like cooking time, ingredients, instructions, servings, and nutritional
content. In the proposed system we utilized the data from the recipes dataset to tailor customized
food recommendations and automatic diet suggestions tailored to the user's demographic and activity
inputs, the major data attributes used for model training are outlined in the following table.
The recommendation engine operates on the Nearest Neighbors algorithm, a type of unsupervised
learning used for conducting neighbor searches. It provides a standardized interface to three distinct
algorithms for identifying nearest neighbors: KDTree, BallTree, and a brute-force method that relies
on functions from sklearn.metrics.pairwise. In our scenario, the brute-force method was selected for
its efficiency in quickly computing results for smaller datasets, utilizing cosine similarity for its
calculations.
1547 JNAO Vol. 15, Issue. 1 : 202

Fig-1: Diet Recommendation Dataset

5. WORKING PROCESS
Our recommendation system uses a content-centric methodology for promoting healthy eating habits.
A content-based recommendation system operates by leveraging the or attributes of items to
recommend analogous items to users. This system functions through the examination of item
content, including text, images, or audio, to detect patterns or attributes linked to specific
items. These identified patterns or attributes are utilized to perform comparisons between items,
thereby enabling the system to suggest similar items to users. Therefore, the system utilizes data on
the nutritional content and components of food items to provide customized recommendations to
users. A notable benefit of the content-based method is its ability to consider an individual's dietary
needs and preferences, including any allergies or specific food likes and dislikes. Through providing
personalized food suggestions, a content-based food suggestion system aids individuals in making
informed dietary choices, thereby enhancing their overall wellness. Moreover, by introducing users
to a range of healthy food options, the system also supports the discovery of new and nutritious
foods, broadening their dietary variety and helping to prevent dietary monotony. These factors
contribute to a more diverse and balanced diet, potentially leading to improved long-term health
outcomes of the user.

Fig-2: Content Based Filtering


1548 JNAO Vol. 15, Issue. 1 : 202

Fig-3: KNN Algorithm

Fig-4: Block Diagram of Machine Learning Model

6. PROJECT MODEL DEVELOPMENT


The core of the system is responsible for recommending recipes based on input data. It utilizes the
nearest neighbors algorithm to find recipes similar to the user's input. Before applying the nearest
neighbors algorithm, it's important to ensure that the input data is on the same scale. The scaling
function standardizes the numerical features of the dataset, making them comparable and improving
the effectiveness of the nearest neighbors algorithm. The Nearest Neighbors Predictor Function sets
up and trains a nearest neighbors algorithm using the pre-processed data. The model is trained to
find recipes in the dataset that are most similar to the user's input in terms of their nutrition content.
In many machine learning workflows, multiple preprocessing steps are applied to the data before
feeding it into the model. The pipeline construction step creates a sequence of such steps, including
standard scaling and nearest neighbors transformation, and ensures they are executed in the correct
order. The input data is prepared for processing by reshaping or preprocessing it as needed. It ensures
that the input is in the appropriate format for further analysis. The Extract Data function filters the
dataset based on the ingredients provided by the user. It selects only those recipes from the dataset
that contain all of the specified ingredients, narrowing down the search space for recommendations.
After filtering the dataset based on ingredients, additional preprocessing may be required for the
filtered data. This step prepares the data for further analysis, ensuring it is in the correct format and
ready for input into the pipeline. Once the data is prepared and the pipeline is constructed, it's time
to apply the pipeline to the input data. This step transforms the input data using the preprocessing
steps defined in the pipeline and retrieves the nearest neighbors from the filtered dataset. Finally, the
output formatting function takes the recommended recipes obtained from the pipeline and formats
them for presentation to the user. It may involve converting the output into a user-friendly format,
such as JSON, and extracting specific information from each recipe, such as ingredients and
instructions.
1549 JNAO Vol. 15, Issue. 1 : 202
Together, these components form a systematic workflow for recommending recipes based on user
input. They ensure that the input data is properly processed, the model is trained and applied
correctly, and the output is presented in a clear and understandable format to the user.

Fig-5: Working Flow of Project Model

7. UI INTERFACE
In the development of the proposed recommendation system for recipes based on input nutrition data
and ingredients, a combination of powerful tools was utilized to create an efficient and scalable
solution. These tools, including FastAPI, Pydantic, pandas, scikit-learn, NumPy, and the regular
expressions module (re), played crucial roles in different aspects of the project, ranging from
building the API endpoints to implementing machine learning algorithms and data preprocessing
techniques[8]
Backend Development:
The application leverages the FastAPI framework to develop rapid and high-performance web APIs.
Upon receiving a request from a user, which could include user information, nutritional details, and
more, the model springs into action, crafting a curated list of food recommendations that align with
the user's input. These suggestions are then delivered back to the user through the API.
Frontend Development:
The application's interface is crafted using Streamlit, a Python-based open-source framework
designed for building web apps efficiently, particularly in the fields of data science and machine
learning[9]. Streamlit supports seamless integration with key Python libraries like scikit-learn, Keras,
PyTorch, SymPy (for LaTeX), NumPy, pandas, and Matplotlib, enhancing its utility for a wide range
of applications. Our application features three distinct web pages. The introductory page, Hello.py,
serves as the entry point, offering users a welcoming overview of the project. A navigation sidebar is
positioned on the left, guiding users to two main functionalities: the automatic diet recommendation
and the custom food recommendation sections. In the diet recommendation segment, users input
personal details such as age, weight, and height to receive tailored diet plans. Meanwhile, the custom
food recommendation page provides an option for users to refine their food choices based on
specific nutritional parameters, catering to more detailed dietary preferences.

8. RESULTS AND DISCUSSIONS


This system aims to leverage OpenAI and ML to generate recommendations for food and exercise
tailored to user inputs, for Automatic Diet recommendation, Users would access a page containing
various input fields which include demographic factors, current dietary habits, and exercise patterns.
This page mainly focuses on weight loss plans which are of 4 variations from maintaining weight to
extreme weight loss. Based on the user inputs, various recipes are recommended.
1550 JNAO Vol. 15, Issue. 1 : 202
For Custom Food Recommendations, a user-friendly interface with sliders will allow users to
precisely input various nutritional values which include caloric value, fat levels, saturated fat
amounts, cholesterol levels, sodium levels, carbohydrate amounts, fiber amounts, sugar levels, and
protein amounts. The user can also select the number of recommendations to be generated at a time
and can specify ingredients to be included in the recommendations. The main purpose of this page is
to allow users to mainly concentrate on overcoming specific nutritional deficiencies, and for
purposes like weight gain.
Finally, the workout Recommendation page asks for the user’s demographic details and any specific
health conditions of the user. With the details of the user, the necessary workouts of various types are
recommended to maintain good health, specific to the particular user. This proposed system offers a
framework for leveraging OpenAI and ML to significantly enhance dietary recommendations to a
specific user. Some key features involved in this system include, BMI and Calorie Calculation used
to assess an individual's body weight to their height, this is used to identify individuals who may be
underweight, normal weight, overweight, or obese. This helps to determine if further evaluation
or interventions are needed to address potential health risks associated with weight status. The
outcomes from the calorie calculator provide daily caloric intake estimates, serving as a guide for the
amount of calories one should consume daily to either maintain, lose, or gain weight according to
their desired pace.
Each recipe/meal item recommended displays data about the image of the item, nutritional values in
it, ingredients to prepare it, recipe instructions, cooking, and preparation time provided by the
dataset. The diet recommendation page contains a graph that displays the total calories chosen for the
specified meal composition and maintains weight calories, which helps users differentiate the various
meal compositions. Both the diet diet guidance page and tailored food suggestion page consist of a
pie chart to visualize the nutritional values in meal composition and food recipe respectively.

9. CONCLUSION AND FUTURE SEARCH


The study " Diet and Workout Recommendation System using Nearest Neighbors" represents a
significant advancement in addressing the growing demand for personalized health and wellness
solutions. By integrating Streamlit for the frontend user interface and the Nearest Neighbors machine
learning algorithm, we have developed a system that offers tailored recommendations to individuals
based on their unique needs and preferences. Our research and development efforts have highlighted
the capabilities of machine learning algorithms in examining user data and generating personalized
recommendations. Through feature engineering and algorithm selection, we have demonstrated the
system's capacity to deliver precise and effective diet and workout suggestions.
The project's vision extends beyond its current implementation, encompassing various avenues for
future enhancement. These include the incorporation of sophisticated machine learning methods,
including deep learning for more accurate predictions and personalized recommendations.
Additionally, the development of a mobile application will enhance accessibility and user
engagement. Furthermore, collaboration with health professionals and fitness experts will ensure that
the recommendations align with established guidelines and best practices. Continuous model training
and updates will also be implemented to adapt to evolving user preferences and health trends.
Overall, these initiatives aim to further improve the relevance of the personalized diet and workout
recommendation system, ensuring its continued utility in promoting healthy behaviors and improving
health outcomes.

REFERENCES:
1. Subramaniyaswamy, V., Manogaran, G., Logesh, R., Vijayakumar, V., Chilamkurti, N.,
Malathi, D., & Senthilselvan, N. (2018). An ontology-driven personalized food recommendation in
an IoT-based healthcare system. The Journal of Supercomputing, 75, 3184-3216.
http://doi.org/10.1007/s11227-018- 2331-8
2. Raggatt, M., Wright, C., Carrotte, E., Jenkinson, R., Mulgrew, K., Prichard, I., & Lim, M.
(2018). "I aspire to look and feel healthy like the posts convey": engagement with fitness inspiration
on social media and perceptions of its influence on health and wellbeing. BMC Public Health, 18.
http://doi.org/10.1186/s12889-018-5930-7
1551 JNAO Vol. 15, Issue. 1 : 202
3. Burke, L., Castell, L., Casa, D., Close, G., Costa, R., Desbrow, B., Halson, S., Lis, D., Melin,
A., Peeling, P., Saunders, P., Slater, G., Sygo, J., Witard, O., Bermon, S., & Stellingwerff, T. (2019).
International Association of Athletics Federations Consensus Statement 2019: Nutrition for
Athletics. International Journal of Sport Nutrition and Exercise Metabolism, 29(2), 73-84.
http://doi.org/10.1123/ijsnem.2019-0065
4. Grgic, J., Grgic, I., Del Coso, J., Schoenfeld, B.J., & Pedisic, Z. (2021). Effects of sodium
bicarbonate supplementation on exercise performance: An umbrella review. Journal of the
International Society of Sports Nutrition, 18(1), 71. https://doi.org/10.1186/s12970-021-00469-7.
5. Schmitz, K.H., Troxel, A.B., Dean, L.T., DeMichele, A., Brown, J.C., Sturgeon, K., Zhang, Z.,
Evangelisti, M., Spinelli, B., Kallan, M.J., Denlinger, C., Cheville, A., Winkels, R.M., Chodosh, L.,
Sarwer, D.B. (2019). Effect of home-based exercise and weight loss programs on breast cancer-
related lymphedema outcomes among overweight breast cancer survivors: The WISER Survivor
randomized clinical trial. JAMA Oncology, 5(11),1605-1613.
https://doi.org/10.1001/jamaoncol.2019.2109
6. Iwendi, C., Khan, S., Anajemba, J.H., Bashir, A., & Noor, F. (2020). Realizing an efficient
IoMT- assisted patient diet recommendation system through machine learning model. IEEE Access,
8, 28474- 28484. https://doi.org/10.1109/ACCESS.2020.2968537
7. Freitas, P., Ferreira, P.G., Silva, A.G., Stelmach, R., Carvalho-Pinto, R., Fernandes, F.L.,
Mancini, M., Sato, M.N., Martins, M., & Carvalho, C. (2017). The role of exercise in a weight-loss
program on clinical control in obese adults with asthma: A randomized controlled trial. American
Journal of Respiratory and Critical Care Medicine, 195, 32-42. https://doi.org/10.1164/rccm.201603-
0446OC
8. Doppala BP, Naga Mallik Raj S, Stephen Neal Joshua E, Thirupathi Rao N (2021) Automatic
determination of harassment in social network using machine learning. https://doi.org/10.1007/978-
981- 16-1773-7
9. NagaMallik Raj, S., Neeraja, S., Thirupathi Rao, N., Bhattacharyya, D. (2023). Multitask Deep
Learning Model for Diagnosis and Prognosis of the COVID-19 Using Threshold-Based
Segmentation with U- NET and SegNet Classifiers. In: Sisodia, D.S., Garg, L., Pachori, R.B.
Tanveer, M. (eds) Machine Intelligence Techniques for Data Analysis and Signal Processing.
Lecture Notes in Electricall Engineering, vol 997. Springer, Singapore. https://doi.org/10.1007/978-
981-99-0085-5.

You might also like