In today's health-conscious world, people are increasingly focused on improving their lifestyle and diet. Avoiding junk food and exercising alone isn't enough; a balanced diet is essential. Tailoring our diet to our height, weight, and age helps maintain a healthy weight, reduce the risk of chronic diseases, and enhance overall health. Noticing the lack of advanced projects in food/diet recommendation, I decided to create a content-based recommendation system using machine learning.
A content-based food recommendation engine promotes healthy eating by analyzing nutritional content and ingredients to provide personalized recommendations. It considers individual dietary restrictions and preferences, such as allergies, to help users make better food choices and improve their overall health. By suggesting a variety of nutritious options, it helps users discover new foods and maintain a balanced diet, positively impacting long-term health outcomes.
The application includes user authentication, allowing users to securely log in and access personalized recommendations. User data and past interactions are stored in a database, enabling the system to provide more accurate and tailored food recommendations based on previous experiences. This approach enhances user engagement and ensures the recommendations are continually improving and relevant to each user.
The recommendation engine is constructed using the Nearest Neighbors algorithm, an unsupervised method for conducting neighbor searches. It provides a consistent interface to three distinct nearest neighbors algorithms: BallTree, KDTree, and a brute-force approach based on routines in sklearn.metrics.pairwise. In our implementation, we utilized the brute-force algorithm with cosine similarity because of its rapid computation for smaller datasets.
$$ cos(θ)= ∥A∥×∥B∥ A⋅B
$$
we used Food.com kaggle dataset Data with over 500,000 recipes and 1,400,000 reviews from Food.com. Visit this kaggle link for more details.
The application is developed with the FastAPI framework, enabling the creation of fast and efficient web APIs. When a user submits a request to the API (including user data, nutrition data, etc.), the model generates a list of recommended foods that match the user's criteria. These recommendations are then sent back to the user through the API.
The application is developed with a React frontend and a Node.js backend. When a user submits data, the backend processes the request and uses the model to generate a list of suitable food recommendations. These recommendations are then sent back to the user through the FASTAPI, ensuring a fast and efficient response.
By using Docker, you can ensure that the environment in which the application is exactly the same as the environment in which it was built, which can help prevent unexpected issues and improve model performance. Additionally, Docker allows for easy scaling and management of the deployment, making it a great choice for larger machine learning projects.
My project is composed of different services (frontend,API). Therefore, our application should run on multiple containers. With the help of Docker-compose we can share our application using the yaml file that define the services that runs together.
The project is created with:
- Python: 3.12.8
- fastapi 0.88.0
- scikit-learn 1.1.3
- Pandas: 1.5.1
- Streamlit: 1.16.0
- Numpy: 1.21.5
- beautifulsoup4 4.11.1

