This project builds a machine learning model to predict cereal crop yield in Mali using real agricultural statistics from FAOSTAT and climate indicators such as rainfall and drought conditions. The goal is to demonstrate how climate variability impacts agricultural productivity and to build a reproducible AI pipeline for agricultural forecasting.
# Mali_Crop_Yield_Prediction
This project builds a machine learning model to predict cereal crop yield in Mali using real agricultural statistics from FAOSTAT and climate indicators such as rainfall and drought conditions. The goal is to demonstrate how climate variability impacts agricultural productivity and to build a reproducible AI pipeline for agricultural forecasting.
Objectives
• Clean and process FAOSTAT agricultural yield data
• Integrate climate data (rainfall + SPI)
• Build a supervised machine learning model
• Predict crop yield using climate indicators
• Evaluate model performance using regression metrics
________________________________________
📊 Datasets Used
1. FAOSTAT Agricultural Data
Source: FAOSTAT (Food and Agriculture Organization)
• Area: Mali
• Item: Cereals, primary
• Variable used: Yield
• Time range: ~1961–2024
📄 File:
FAOSTAT_data_en_6-28-2026.csv
________________________________________
2. Climate Data (SPI + Rainfall)
• Annual rainfall (mm)
• Standardized Precipitation Index (SPI)
📄 File:
mali_spi_results(2).csv
________________________________________
🧹 Data Processing Workflow
Step 1: FAOSTAT Cleaning
• Removed irrelevant columns
• Filtered Element = Yield
• Renamed target column to yield_t_ha
• Kept only cereals data
Step 2: Climate Aggregation
• Converted monthly SPI to yearly values
• Aggregated rainfall and SPI by year:
o Annual rainfall mean
o Annual SPI mean
Step 3: Data Merge
Merged datasets on:
Year
Final dataset:
mali_crop_yield_climate_merged.csv
________________________________________
📦 Final Dataset Structure
Year yield_t_ha annual_rainfall_mm annual_spi
1981 837.9 90.48 -0.146
1982 785.0 86.00 0.035
________________________________________
🤖 Machine Learning Model
Model Used
• Random Forest Regressor (scikit-learn)
Features (X)
• annual_rainfall_mm
• annual_spi
Target (y)
• yield_t_ha
________________________________________
⚙️ Model Pipeline
1. Train/test split (80/20)
2. Model training
3. Prediction
4. Evaluation
___ …