This project predicts crop yield (in tonnes/hectare) based on historical data including weather (rainfall, temperature), soil properties (pH, nitrogen, etc.), and crop type. It uses machine learning models and includes a web-based frontend for user interaction and data visualization.
- Predict yield based on soil and weather parameters.
- Enable user-friendly input via frontend.
- Display predictions and data insights using visualizations.
- Aid farmers and agriculture planners in better decision-making.
| Area | Technology |
|---|---|
| Programming | Python 3 |
| Machine Learning | scikit-learn, pandas, NumPy |
| Visualization | matplotlib, seaborn, Plotly |
| Backend | Flask |
| Frontend | HTML, CSS, JavaScript (Bootstrap) |
| Model | Linear Regression / Random Forest |
| Deployment | Localhost / Flask server |
crop_data.csv- Columns:
- Crop
- Rainfall (mm)
- Temperature (°C)
- pH
- Nitrogen (N)
- Phosphorus (P)
- Potassium (K)
- Yield (tonnes/hectare)
- Columns:
📌 Note: Dataset can be collected from Kaggle, ICAR (India), or FAO sources.
- ✅ Crop yield prediction using trained ML model
- ✅ Frontend form for user input
- ✅ Visualization of dataset and predictions
- ✅ Downloadable prediction report (optional)
- ✅ Responsive UI using Bootstrap
- Correlation Heatmap
- Crop-wise Yield Bar Plot
- Scatter Plot: Rainfall vs Yield
git clone https://github.com/yourusername/crop-yield-predictor.git
cd crop-yield-predictorpip install -r requirements.txtpython app.pyVisit: http://127.0.0.1:5000
├── static/
│ └── style.css
├── templates/
│ ├── index.html
│ ├── result.html
│ └── visualize.html
├── crop_data.csv
├── app.py
├── model.pkl
├── requirements.txt
└── README.md
- Model Used: Random Forest Regressor (can switch to Linear Regression)
- Accuracy: ~90% (varies with dataset)
- Target Variable: Yield (tonnes/hectare)
- Home Page: Enter soil, weather, crop details
- Prediction Page: Displays predicted yield
- Visualization Page: Shows charts (bar, heatmap, scatter)
Crop: Rice
Rainfall: 120 mm
Temperature: 28°C
pH: 6.5
N: 80
P: 45
K: 40
Predicted Yield: 3.8 tonnes/hectare
- Bar chart of yield by crop
- Heatmap showing correlation of features
- Scatter plot for rainfall vs yield
- Name: Charan Basava
- GitHub: CharanBasava
This project is open-source and available under the MIT License.