Skip to content

Dewang007/ChatBot-Food

Repository files navigation

🍽️ Food Dish Recommender System

An AI-powered dish recommendation system that suggests meals based on your preferences, mood, dietary restrictions, and allergies using content-based filtering and weighted scoring algorithms.

✨ Features

  • Smart Recommendations: Content-based filtering with multi-factor scoring
  • Safety First: Hard filters for allergies and dietary restrictions
  • Mood-Based: Get dishes that match your current mood
  • Comprehensive Database: 10,000+ real recipes from Kaggle datasets
  • Explainable AI: Understand why each dish was recommended
  • Cuisine Diversity: 20+ international cuisines
  • Allergen Detection: Automatic allergen identification from ingredients

🧠 How It Works

The recommendation engine uses a weighted scoring system:

Final Score = (
    Preference Match × 40% +
    Mood Alignment × 30% +
    Cuisine Preference × 20% +
    Diversity Bonus × 10%
) × Allergy Filter

Scoring Components

  1. Preference Match (40%): Matches your favorite ingredients
  2. Mood Alignment (30%): Aligns with your current mood (comfort, energizing, light, etc.)
  3. Cuisine Preference (20%): Prioritizes your favorite cuisines
  4. Diversity Bonus (10%): Encourages variety by boosting less common options

Hard Filters

Before scoring, dishes are filtered by:

  • ❌ Allergens (e.g., nuts, dairy, gluten)
  • ❌ Dietary restrictions (vegan, vegetarian, gluten-free, etc.)
  • ❌ Disliked ingredients
  • ❌ Spice level tolerance
  • ❌ Time constraints
  • ❌ Calorie limits
  • ❌ Meal type

📊 Data Sources

Uses real-world Kaggle datasets:

  1. Recipe Ingredients Dataset (~40,000 recipes with cuisine classification)
  2. Food Ingredients and Recipe Dataset with Images (13,582 recipes with images)
  3. Ingredients with 16 Allergen Tags (10,000 USDA ingredients with allergen info)

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Kaggle account and API credentials

Installation

  1. Clone the repository

    cd food-dish-recommender-system
  2. Install dependencies

    pip install -r requirements.txt
  3. Setup Kaggle credentials

    • Go to https://www.kaggle.com/settings/account
    • Scroll to "API" section
    • Click "Create New Token" to download kaggle.json
    • Place it in:
      • Windows: C:\Users\<YourUsername>\.kaggle\kaggle.json
      • Linux/Mac: ~/.kaggle/kaggle.json
  4. Download datasets

    python scripts/setup_kaggle.py

    This will download ~500MB of recipe data.

  5. Process datasets

    python scripts/process_data.py

    This merges, cleans, and enriches the data (takes 2-5 minutes).

  6. Run the recommender!

    python src/main.py

💡 Usage Example

🍽️  FOOD DISH RECOMMENDER SYSTEM
=====================================

Tell me about your preferences!

🚨 ALLERGIES: nuts, dairy
🥗 DIETARY RESTRICTIONS: vegetarian
😊 CURRENT MOOD: 2 (energizing)
🌍 FAVORITE CUISINES: Italian, Thai
❤️  FAVORITE INGREDIENTS: pasta, basil, garlic

🔍 Finding perfect dishes for you...

🎯 YOUR PERSONALIZED RECOMMENDATIONS
=====================================

Recommendation #1
─────────────────────────────────────
🍽️  Garlic Basil Pasta (Italian)
Match Score: 87%

Why this dish:
  ✅ Contains ingredients you love (92% match)
  ✅ Perfect for your current mood (100% match)
  ✅ One of your favorite cuisines (100% match)
  ⏱️  Total time: 20 minutes
  🥗 vegetarian, dairy-free

📁 Project Structure

food-dish-recommender-system/
├── src/
│   ├── models.py                    # Data models (Dish, UserPreferences)
│   ├── recommendation_engine.py     # Core recommendation algorithm
│   ├── data_processor.py            # Dataset processing and enrichment
│   └── main.py                      # CLI application
├── scripts/
│   ├── setup_kaggle.py              # Download Kaggle datasets
│   └── process_data.py              # Process and merge datasets
├── data/
│   ├── raw/                         # Raw Kaggle datasets (gitignored)
│   └── processed/                   # Processed dish database (gitignored)
├── requirements.txt                 # Python dependencies
├── .env.example                     # Environment configuration template
└── README.md                        # This file

🎯 Algorithm Details

Content-Based Filtering

The system uses content-based filtering where dishes are recommended based on:

  • Ingredient similarity to user preferences
  • Cuisine type matching
  • Mood tag alignment
  • Allergen and dietary compatibility

Mood Tag Generation

Mood tags are automatically generated using keyword analysis:

  • Comfort: Keywords like "creamy", "hearty", "warming", "traditional"
  • Light: Keywords like "fresh", "salad", "crisp"
  • Energizing: High-protein dishes, Asian cuisine
  • Indulgent: Desserts, chocolate, rich ingredients
  • Healthy: Nutritious ingredients, superfoods
  • Refreshing: Cold dishes, citrus, summer foods
  • Adventurous: Exotic cuisines, fusion dishes

Allergen Detection

Two-stage allergen detection:

  1. Direct lookup in USDA allergen database (10,000 ingredients)
  2. Keyword matching for common allergens in ingredient names

Supported allergens:

  • Dairy (milk, cheese, butter, cream)
  • Nuts (tree nuts, almonds, walnuts, cashews)
  • Peanuts
  • Eggs
  • Soy
  • Wheat
  • Gluten
  • Fish
  • Shellfish
  • Sesame
  • Sulfites

🔧 Configuration

Copy .env.example to .env and customize:

# Recommendation Settings
MIN_MATCH_SCORE=0.3          # Minimum score threshold (0-1)
MAX_RECOMMENDATIONS=10       # Maximum results to return

# Data Paths
DATA_DIR=./data
PROCESSED_DATA_DIR=./data/processed
DB_PATH=./data/dishes.db

📈 Future Enhancements

  • Machine learning model for better mood detection
  • Collaborative filtering using user ratings
  • Recipe image search
  • Nutritional optimization
  • Meal planning for multiple days
  • Web UI with React
  • REST API with FastAPI
  • User profiles and history tracking
  • Social features (share recipes, rate dishes)

🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

MIT License - feel free to use this project for learning or commercial purposes.

🙏 Acknowledgments

  • Kaggle for providing comprehensive recipe datasets
  • USDA for allergen information database
  • Community contributors to open food datasets

📞 Support

For issues or questions:

  • Create an issue on GitHub
  • Check existing issues for solutions

🍕 Enjoy Your Meal

Happy cooking! 🎉


Built with ❤️ for food lovers everywhere

About

This is a Chatbot for Food Website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages