An intelligent, end-to-end Machine Learning and Optimization system built in Python. The system aims to predict food surplus from restaurants, forecast food demand in vulnerable regions, cluster high-waste and high-demand hotspots, and match and route surplus food to NGOs efficiently using Google OR-Tools.
(Recruiters: This project encompasses full-stack data science, from synthetic data generation and predictive modeling to interactive Streamlit dashboards and VRP route optimization.)
Impact analytics showing total meals delivered, food saved, carbon footprint reduction, and AI Surplus Risk scores.
Folium maps highlighting restaurant and NGO locations, alongside Google OR-Tools optimized delivery routes.
Actual vs. Predicted regression plots for waste prediction, and Random Forest feature importance charts.
- Synthetic Data Generation: Simulates restaurants, NGOs, food surplus, and demand.
- Machine Learning Models:
- Waste Prediction: Predicts future surplus amounts and probabilities using Random Forest, Gradient Boosting, etc.
- Demand Prediction: Forecasts food demand based on population density, poverty index, weather, and events.
- Expiry Prediction: Estimates the risk of food spoiling based on distance, traffic, temperature, and food category.
- Clustering: K-Means clustering to visualize high-waste and high-demand geographic hotspots.
- AI Insights Module:
- Live prediction engine assigning a "Surplus Risk %" to active restaurants.
- Optimization Algorithms:
- Intelligent Matching: Pairs restaurants with surplus food to the best-suited NGOs based on distance and capacity.
- Route Optimization: Solves the Vehicle Routing Problem (VRP) / Traveling Salesman Problem (TSP) using Google OR-Tools to minimize volunteer fleet travel distance while fulfilling matched pickups and deliveries.
- Interactive Dashboard: A Streamlit web application visualizing all predictions, clustered heatmaps, optimized routes, and impact analytics.
- Language: Python
- Data Manipulation & ML:
pandas,numpy,scikit-learn - Optimization:
ortools(Google OR-Tools) - Visualization & Dashboard:
streamlit,plotly,folium,streamlit-folium
Smart_Food_Distribution/
│
├── data/ # Generated synthetic datasets & clustering/matching results
├── docs/ # Project documentation and screenshots
│ └── screenshots/
├── src/
│ ├── data_generator/ # Script to generate synthetic data
│ │ └── data_generator.py
│ ├── features/ # Feature engineering scripts
│ ├── models/ # ML prediction and clustering scripts
│ │ ├── waste_prediction.py
│ │ ├── demand_prediction.py
│ │ ├── expiry_prediction.py
│ │ └── clustering.py
│ ├── optimization/ # Matching and Routing algorithms
│ │ ├── matching.py
│ │ └── routing.py
│ └── dashboard/ # Streamlit Web App
│ └── app.py
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Ensure you have Python installed. Run:
pip install -r requirements.txt
# Ensure new map libraries are installed
pip install folium streamlit-foliumRun the pipeline to generate data, train ML models, and calculate optimization routes.
# 1. Generate Synthetic Data
python src/data_generator/data_generator.py
# 2. Train and Run Machine Learning Models
python src/models/waste_prediction.py
python src/models/demand_prediction.py
python src/models/expiry_prediction.py
python src/models/clustering.py
# 3. Run Optimization (Matching and Routing)
python src/optimization/matching.py
python src/optimization/routing.pyFinally, visualize the results by launching the Interactive Dashboard:
streamlit run src/dashboard/app.pyOpen the URL provided in your terminal (usually http://localhost:8501) in your browser to explore the Impact Analytics, Heatmaps, and Optimized Routes maps.
To fetch live nearby restaurants and NGOs for any searched city, add a Google Maps Platform API key using one of these options:
# Option 1: local .env file
copy .env.example .envThen set:
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_hereYou can also provide the same key through Streamlit secrets in .streamlit/secrets.toml or an exported environment variable. The dashboard checks these sources in that order.