Skip to content
프로젝트

소개

A full-stack diet recommendation system using machine learning

AI 및 머신러닝

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

CI DOI Ruff

NutriMind

A content-based diet recommendation web app built with Scikit-Learn, FastAPI, and Streamlit.


Table of Contents


Star History


Overview

A full-stack diet recommendation system that generates personalized meal plans based on user health data (age, weight, height, activity level) or custom nutritional targets. The recommendation engine uses a content-based approach with cosine similarity over nutritional vectors to find the closest matching recipes from a dataset of 500,000+ Food.com recipes.

Key features:

  • Automatic meal plan generation from personal health metrics (BMI, BMR, TDEE)
  • Custom food search by nutritional values and ingredients
  • Configurable weight loss plans (maintain, mild, moderate, extreme)
  • Interactive nutritional breakdown charts

Architecture

Architecture diagram

How It Works

Recommendation Engine

Recipes are embedded as 9-dimensional nutritional vectors (Calories, Fat, Saturated Fat, Cholesterol, Sodium, Carbohydrates, Fiber, Sugar, Protein). A NearestNeighbors model with cosine similarity finds the closest recipes to a given target vector.

Automatic Meal Plan (/generate-meal-plan/)

  1. BMI — weight(kg) / height(m)²
  2. BMR — Mifflin-St Jeor equation
  3. TDEE — BMR × activity multiplier
  4. Target calories — TDEE × weight-loss factor
  5. Calories are distributed across meals (35/40/25% for 3 meals, etc.)
  6. Per-meal nutrition vectors are sampled from physiologically appropriate ranges and passed to the nearest-neighbor model

Ingredient Filtering

At startup, each recipe's ingredient list is pre-parsed into a frozenset of lowercase strings. Filtering then uses set-based substring matching — no regex scanning on every request.

Content-Based Approach

Advantage Note
No cold-start problem Works without any user history
Transparent recommendations Results are directly tied to nutritional targets
No inter-user data needed Fully self-contained per request

Tech Stack

Component Technology
Backend API FastAPI 0.115, Python 3.12
ML / Recommendation scikit-learn 1.4 (NearestNeighbors, cosine)
Data processing pandas 2.2, numpy 1.26
Frontend Streamlit 1.35
Charts streamlit-echarts 0.4
Containerization Docker, Docker Compose


Setup

Prerequisites

Run with Docker Compose

Option A — Use pre-built images (fastest, no build step):

git clone https://github.com/zakaria-narjis/nutrimind
cd nutrimind
docker compose pull
docker compose up -d

Option B — Build from source:

git clone https://github.com/zakaria-narjis/nutrimind
cd nutrimind
docker compose up --build -d

Open http://localhost:8501 in your browser.

The frontend waits for the backend health check to pass before starting. The backend loads the ~95MB dataset at startup, so the first boot takes ~30–60 seconds.

Hosted Version

https://diet-recommendation-system.streamlit.app/


API Reference

Interactive docs are available at http://localhost:8080/docs when the backend is running.

POST /generate-meal-plan/

Generates a full daily meal plan from personal health data.

Request body:

{
  "age": 28,
  "height": 175,
  "weight": 70,
  "gender": "Male",
  "activity": "Moderate exercise (3-5 days/wk)",
  "number_of_meals": 3,
  "weight_loss": "Maintain weight"
}

Response: BMI, BMR, daily calorie targets, and recommended recipes per meal.

POST /predict/

Finds recipes matching a custom 9-value nutrition vector with optional ingredient filtering.

Request body:

{
  "nutrition_input": [500, 20, 3, 50, 800, 60, 8, 5, 30],
  "ingredients": ["chicken", "garlic"],
  "params": {"n_neighbors": 5, "return_distance": false}
}

Dataset

Food.com recipes dataset — 500,000+ recipes from Kaggle.


Citation

@software{narjis_2024_12507829,
  author       = {Narjis, Zakaria},
  title        = {Diet recommendation system},
  month        = jun,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {v1.0.1},
  doi          = {10.5281/zenodo.12507829},
  url          = {https://doi.org/10.5281/zenodo.12507829}
}

관련 프로젝트 살펴보기

불러오는 중…