You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star0 (0)You must be signed in to star a repository
About
District-wise daily tomato price and arrival forecasting for Indian markets, with a focus on Karnataka. Combines 10 data sources into 150+ ML features, trains LightGBM/XGBoost/Random Forest models, and generates multi-horizon price forecasts with confidence intervals.
District-wise daily tomato price and arrival forecasting for Indian markets, with a focus on Karnataka. Combines 10 data sources into 150+ ML features, trains LightGBM/XGBoost/Random Forest models, and generates multi-horizon price forecasts with confidence intervals.
What It Does
10 Data Sources ──> SQLite DB ──> 150+ Features ──> 3 Model Types ──> Price Forecasts
(scrapers) (database) (feature eng.) (walk-forward CV) (1/7/14/30 day)
Data Type
Source
Frequency
API Key?
Mandi prices + arrivals
agmarknet.gov.in
Daily
No
Weather + soil moisture
Open-Meteo
Daily
No
Diesel/fuel prices
goodreturns.in / data.gov.in
Daily
No
INR/USD exchange rate
frankfurter.app
Daily
No
Vegetation health (NDVI proxy)
NASA POWER
Daily
No
Reservoir water levels
data.gov.in / seasonal model
Weekly
No
CPI (vegetables/food)
data.gov.in / MOSPI reference
Monthly
Yes*
WPI (wholesale prices)
data.gov.in / OEA reference
Monthly
Yes*
Fertilizer prices
Government gazette (config)
Quarterly
No
Trade policy events
DGFT notifications (config)
Event-based
No
*data.gov.in key is already configured. All other sources are completely free with no keys required.
# Everything: scrape all data -> engineer features -> train models -> forecast
python3 run_pipeline.py --threads 4
# This will take a while on first run (fetching ~4 years of data).# Subsequent runs are incremental — duplicates are skipped automatically.
3. Check Results
# Forecasts are printed to console and saved to:
cat output/forecasts.csv
# Database stats
python3 main.py --stats
# Evaluate model accuracy
python3 model_trainer.py --evaluate
Common Workflows
# Already have data? Just retrain + forecast
python3 run_pipeline.py --skip-scrape --threads 4
# Already trained? Just forecast with saved models
python3 run_pipeline.py --skip-scrape --skip-train
# Quick test: LightGBM only, skip slow NDVI fetch
python3 run_pipeline.py --skip-ndvi --models lightgbm --no-quantile
# Forecast specific regions
python3 run_pipeline.py --skip-scrape --regions Kolar Nashik Madanapalle
# Predict for a single district
python3 model_trainer.py --predict --district Kolar
# Scrape only specific data
python3 main.py --additional-data # Macro data only
python3 main.py --weather-only --threads 4
python3 main.py --agmarknet --threads 4
Project Structure
santhe-scraper/
|
|-- run_pipeline.py # One-command full pipeline (recommended entry point)
|-- main.py # CLI with granular control over individual steps
|-- model_trainer.py # ML training, evaluation, prediction
|-- feature_engineer.py # 150+ feature creation from raw data
|-- database.py # SQLite storage (11 tables, upsert/dedup)
|-- config.py # All settings, GPS coords, API keys, constants
|
|-- Scrapers:
| |-- scraper_agmarknet_gov.py # Price + arrival (agmarknet.gov.in API)
| |-- scraper_weather.py # Weather + soil (Open-Meteo, free)
| |-- scraper_diesel.py # Diesel/fuel prices
| |-- scraper_forex.py # INR/USD exchange rate (frankfurter.app)
| |-- scraper_ndvi.py # Vegetation health (NASA POWER)
| |-- scraper_reservoir.py # Dam water levels (Karnataka)
| |-- scraper_cpi.py # Consumer Price Index
| |-- scraper_wpi.py # Wholesale Price Index
| |-- scraper_fertilizer.py # Fertilizer prices (config-driven)
| |-- scraper_trade_policy.py # Export/import bans (config-driven)
| |-- scraper_agmarknet.py # data.gov.in API (legacy)
| |-- scraper_ceda.py # CEDA Ashoka API (legacy)
|
|-- output/
| |-- santhe_tomato.db # SQLite database (all data)
| |-- models/ # Trained model pickles + metadata
| |-- forecasts.csv # Latest predictions
| |-- tomato_prices_daily.csv # Exported price data
| |-- weather_daily.csv # Exported weather data
| |-- tomato_model_features.csv
|
|-- docs/
| |-- DATA_SOURCES.md # Detailed scraper documentation
| |-- PIPELINE.md # Feature engineering + model training details
CLI Reference
run_pipeline.py (Recommended)
Runs the complete pipeline in one command.
Flag
Description
--threads N
Parallel scraping threads (default: 1, max: 8)
--start-date
Start date YYYY-MM-DD (default: 2021-02-01)
--end-date
End date YYYY-MM-DD (default: today)
--regions X Y Z
Districts to forecast (default: Kolar, Chikkaballapur, Bangalore, Belagavi, Nashik)
--models
Model types: lightgbm, xgboost, random_forest (default: all)
District-wise daily tomato price and arrival forecasting for Indian markets, with a focus on Karnataka. Combines 10 data sources into 150+ ML features, trains LightGBM/XGBoost/Random Forest models, and generates multi-horizon price forecasts with confidence intervals.