Built for farmers who want a clear answer and for engineers who want to understand exactly how that answer was produced.
The Problem
Crop selection in India is still largely driven by tradition and word-of-mouth. A farmer who picks the wrong crop for a given district and season can lose an entire season's income. We set out to build a system that turns decades of historical agricultural records into a single, actionable recommendation.
Dataset Construction
Three public datasets were collected, cleaned, and merged to build the training set:
District Crop Production (Ministry of Agriculture) — Crop name, area sown, and production quantity at district level across multiple decades and Indian states.
State-level Rainfall Data (IMD) — Annual and seasonal rainfall figures used as a climate proxy, since fine-grained district rainfall data is sparse.
Wholesale Market Prices (Agmarknet) — Average modal prices per crop used to estimate revenue from predicted yield.
After merging on state, district, crop, and season keys, records with missing production or price data were dropped. Average yield (production / area) and expected revenue per hectare were derived as target-adjacent features.
Model 1 — Crop Classifier (Stacking Ensemble)
What it does: Given a district, state, season, area, rainfall, and historical yield, it predicts the single most profitable crop to grow.
Architecture: A two-layer stacking classifier. The base layer consists of three independently trained models — Random Forest, Gradient Boosting Classifier, and AdaBoost — each producing probability estimates across all crop classes. These out-of-fold predictions are fed as features to a Logistic Regression meta-learner, which produces the final class output. Stacking was chosen over a single model because each base learner captures different non-linear patterns, and the meta-learner learns how to weight them optimally.
Inputs: State, district (label-encoded), season (label-encoded), land area, average rainfall, average historical yield.
Model 2 — Revenue Regressor (Gradient Boosting)
What it does: Predicts expected revenue per hectare for the recommended crop in a given district and season.
Architecture: A Gradient Boosting Regressor trained on historical revenue per hectare, calculated from production records and market prices. The model captures non-linear interactions between district, season, crop type, and yield history. The app applies a ±20% band around the point estimate to reflect realistic market price volatility.
Map & Fallback Logic
The interactive map uses Leaflet.js with a district-level GeoJSON of India. Each polygon is pre-annotated with its nearest matching model district via string similarity. Districts not in the training vocabulary fall back to the nearest supported district — the location strip shows exactly which district's data was used.
Crop Revenue Advisor
Data-driven crop recommendations for any Indian district.
Enter a district, growing season, and farm area. Get a crop recommendation and projected revenue estimate from a trained machine learning pipeline.