This repository contains the machine learning backend for a lifestyle recommendation system.
The project consists of a Python-based machine learning model that is deployed as a Flask API. This API is designed to be consumed by a separate Android mobile application, which handles the user interface.
The goal of this project is to recommend lifestyle choices (e.g., diet, exercise, activities) to users based on their input. The ML model provides the "brain," and the Android app provides the "face."
This system works in two parts:
-
Machine Learning API (This Repository):
- A model is trained in the Jupyter Notebooks (
Cleaning.ipynb,EDA.ipynb,Modeling.ipynb). - The trained model is saved in the
/modelsdirectory. - The
flask_app.pyfile loads the model and exposes it as a web API. An endpoint (e.g.,/predict) receives data from the app and returns the model's recommendation as a response.
- A model is trained in the Jupyter Notebooks (
-
Android App (Separate Project):
- A native Android app (likely built in Kotlin or Java) provides the user interface.
- When a user requests a recommendation, the app sends an HTTP request (e.g., using Retrofit or Volley) to the running Flask API.
- The app receives the API's response (e.g., in JSON format) and displays the recommendation to the user.
This project uses two separate regression models, both built with sklearn.ensemble.RandomForestRegressor and packaged into Scikit-learn Pipelines.
- Purpose: Predicts the optimal Session Duration (hours) and Calories Burned based on user biometrics.
- Algorithm:
RandomForestRegressor(n_estimators=10) - Features:
Age,Gender,Weight (kg),Height (m),Experience_Level - Performance: R-squared: 75.36%
- Saved File:
models/workout_goal_pipeline.joblib
- Purpose: Predicts the nutritional content (Calories, Proteins, Carbs, Fats) of a meal.
- Algorithm:
RandomForestRegressor(n_estimators=10) - Features:
Age,Gender,Weight (kg),Height (m),diet_type,cooking_method,serving_size_g - Performance: R-squared: 91.91%
- Saved File:
models/meal_macro_pipeline.joblib
- Machine Learning: Python, Pandas, Scikit-learn (
RandomForestRegressor,Pipeline) - API: Flask
- Data Analysis: Jupyter Notebook
- Model Saving: Joblib
-
Clone the repository:
git clone [https://github.com/RaymussenArthur/Life-Style-Recommendation.git](https://github.com/RaymussenArthur/Life-Style-Recommendation.git) cd Life-Style-Recommendation -
Create a virtual environment (Recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the Flask API server:
flask run # Or: python flask_app.pyThe API will now be running. The Android app can now use the API and send requests to this address.
Link to Android App Repo: brb_