Empowering Farmers with Data-Driven Insights
A web-based machine learning application that predicts crop prices to help farmers make informed selling decisions and reduce dependency on middlemen.
- Farmers suffer significant losses due to unpredictable crop prices
- Lack of forecasting tools tailored to local agriculture
- Decisions based on guesswork instead of data-driven insights
- Heavy dependency on middlemen for price information
AgroNomics provides a comprehensive web-based ML tool that:
- Forecasts crop prices for upcoming periods
- Uses historical datasets and regression models
- Offers a simple, intuitive interface accessible to farmers
- Covers multiple crop categories across Indian states
- Predicts crop prices based on location, season, and commodity type
- Covers 9 major crop categories with 200+ commodities
- State and district-wise predictions across India
- Grains: Wheat, Rice, Maize, Millets, Barley, etc.
- Pulses: Arhar Dal, Masur Dal, Green Peas, etc.
- Vegetables: Onion, Potato, Tomato, Cabbage, etc.
- Fruits: Banana, Mango, Apple, Orange, etc.
- Spices: Turmeric, Ginger, Garlic, Black Pepper, etc.
- Cash Crops: Cotton, Sugarcane, Coffee, Tobacco, etc.
- All 28 Indian states and 8 Union Territories
- District-level granularity for precise predictions
- 700+ districts covered
- Summer (Zaid): March-June
- Monsoon (Kharif): June-September
- Post-Monsoon: October-November
- Winter (Rabi): December-March
| Technology | Purpose |
|---|---|
| Python 3.13 | Core logic & scripting |
| Pandas, NumPy | Data processing & computation |
| scikit-learn | ML models (Random Forest, DT) |
| Flask | Web backend & REST API |
| Joblib | Model serialization |
| HTML/CSS/JS | Frontend interface |
- Python 3.11+
pip(Python package installer)
- Clone the repository
git clone https://github.com/yourusername/AgroNomics.git cd AgroNomics - Create a Virtual Environment
python -m venv venv source venv/bin/activate # For Linux/Mac venv\Scripts\activate # For Windows
- Install Dependencies
pip install -r requirements.txt
- Add Model Files Run Agronomics.ipynb Place your model.pkl and encoder.pkl files inside the project directory. (Ensure these files are present for predictions to work.)
- Run the Flask App python app.py Your app will be available at: http://127.0.0.1:5000
.
└── AgroNomics/
├── assets/
│ ├── agridata.csv (original dataset from Kaggle)
│ ├── cleaned_agridata.csv (cleaned dataset for model building)
│ └── crops.docx
├── static (frontend styling & logic)/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── script.js
├── templates (frontend structure)/
│ ├── about.html
│ ├── copyright.html
│ ├── home.html
│ └── result.html
├── requirements.txt
├── AgroNomics.ipynb (final model code)
├── model.plk (final model)
├── encoder.plk (encoding for model)
├── app.py (Flask API)
├── LICENSE
└── README.md
User Input → Flask Backend → ML Model → Price Prediction → Web Interface
- User Input: State, District, Crop Category, Crop, Month, Season.
- Backend (Flask): Processes input and calls the ML model.
- ML Model (Random Forest): Predicts the crop price using trained data.
- Price Prediction: Returns modal price per kilogram.
- Web Interface: Displays the results in a clean and user-friendly manner. Print Result.
-
Open the homepage.
-
Select State, District, Crop Category, Crop, Month, and Season.
-
Click "Predict Price" to view the estimated price (₹/kg).
- Dataset: https://www.kaggle.com/datasets/syedjaferk/agriculture-commodity-data-2019
- Algorithm: Random Forest Regression with fallback prediction system
- Features: Category, Crop, State, District, Month, Season
- Encoding: Ordinal Encoding for categorical variables
- Fallback System: Rule-based predictions when ML models unavailable
- Accuracy: ~88% on cleaned dataset (~40k entries)
| Metric | Value |
|---|---|
| MAE | 3.25 |
| RMSE | 5.64 |
| R² | 0.88 |
Top Features (by importance): Crop > Category > State > District > Month > Season
- Model Loading Error: Ensure
model.pklandencoder.pklare in the project directory. - Missing Templates: All HTML files must be in the
templates/folder. - Port in Use: Stop other processes or use
python app.py --port=5001.
| Name | Role | Contact |
|---|---|---|
| Sangini Garg | Developer | GitHub |
