Machine learning model designed to predict maize and soyabean yields in Mashonaland West, Zimbabwe.
This project compares multiple algorithms - including Random Forest, XGBoost, ANN, and Linear Regression - to identify the most accurate approach for agricultural forecasting.
Introduction
Agriculture is the backbone of Zimbabwe's economy, yet climate variability, poor farming practices, and limited technology adoption have contributed to declining crop yields.
The goal of this thesis project was to leverage machine learning to predict yields for maize and soyabeans, two staple crops, while identifying the most influential factors driving productivity.
Research Aim
To perform a comparative analysis of XGBoost, Linear Regression, Random Forest, and Artificial Neural Network models for predicting crop yields in Mashonaland West.
Research Objectives
- Identify the main factors influencing maize and soyabean crop yields.
- Design and implement yield prediction models using XGBoost, Linear Regression, Random Forest, and ANN.
- Compare model performance using standard evaluation metrics.
- Recommend the best-performing model for real-world use.
Methodology
This study followed the CRISP-DM framework:
- Data Collection: Climatic, management, and crop-specific data were gathered from the seven districts of Mashonaland West - Chegutu, Hurungwe, Kadoma, Kariba, Makonde, Mhondoro-Ngezi, and Zvimba.
- Data Preprocessing: Cleaning, normalization, and encoding were applied to ensure compatibility with ML algorithms.
- Model Training: Implemented in Python using
scikit-learn,xgboost, andtensorflow. - Model Evaluation: Compared using MSE, MAE, and R-score.
Records distribution chart (coming soon).
Dataset Features
- Climatic: Rainfall, temperature, humidity
- Management: Fertilizer, pesticide, herbicide usage
- Crop-specific: Area under cultivation, farming scale (small-scale, large-scale, A2)
Models Implemented
- Linear Regression (LR) - interpretable baseline.
- Random Forest (RF) - strong ensemble method for non-linear data.
- XGBoost (XGB) - optimized gradient boosting for high accuracy.
- Artificial Neural Network (ANN) - deep learning approach for complex relationships.
Evaluation Metrics
- MSE - Mean Squared Error
- MAE - Mean Absolute Error
- R-score - Explained variance
Results
| Model | R-score |
|---|---|
| Random Forest | 0.8753 |
| XGBoost | 0.8709 |
| ANN | 0.8481 |
| Linear Regression | 0.7254 |
Base models evaluation chart (coming soon).
Key Insights
- Random Forest achieved the highest accuracy (R = 0.8753).
- XGBoost was a close second, making it a strong alternative.
- ANN showed potential but required more tuning.
- Linear Regression underperformed due to non-linearity in data.
Feature Importance
Feature importance analysis revealed that area under cultivation, farming scale, and pesticide/herbicide value were the most significant predictors.
Feature importance plot (coming soon).
Conclusions
- Best Model: Random Forest for yield prediction in Mashonaland West.
- Practical Use: Supports data-driven agricultural planning and precision farming.
- Policy Recommendations:
- Promote climate resilience strategies.
- Increase technology adoption for farmers.
- Expand agricultural data collection programs.
Video Demo
Installation & Usage
Prerequisites
- Python 3.8+
- Jupyter Notebook
- Libraries:
numpy,pandas,scikit-learn,xgboost,tensorflow,matplotlib,seaborn
Setup
git clone https://github.com/tinolinton/Yield-Predictive-Model.git
cd Yield-Predictive-Model
pip install -r requirements.txt
jupyter notebook