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 face significant financial losses due to unpredictable crop prices, lack of reliable forecasting tools, and decisions based on guesswork rather than data-driven insights.
AgroNomics is a web-based machine learning platform that predicts upcoming crop prices using historical datasets and advanced regression models. It provides a clean, intuitive interface designed for farmers, offering state and district-level insights across multiple crop categories in India.
- Accurate Price Prediction: Forecasts crop prices based on state, district, season, and crop type using advanced ML models.
- Extensive Crop Database: Covers 9 major crop categories with 200+ commodities, including grains, pulses, vegetables, fruits, spices, and cash crops.
- Nationwide Coverage: Supports all 28 states, 8 union territories, and 700+ districts across India.
- Seasonal Intelligence: Considers seasonal variations (Zaid, Kharif, Post-Monsoon, and Rabi) for precise predictions.
- AgriTech Growth: $30.6B (2024) → $79.7B (2030) globally, with India projected to reach $24-30B by 2027 (~50% CAGR).
- Key Benefits:
- Reduces farmer losses due to price volatility
- Promotes data-driven agriculture
- Decreases dependency on middlemen
| 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
├── sample_models (rough models built)/
│ ├── model1
│ ├── model2
│ ├── model3
│ └── delete.py
├── 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 |
|---|---|---|
| Vaibhavi Srivastava | ML Developer | GitHub |
| Sangini Garg | Web Developer | GitHub |
