Machine Learning comparison of 4 algorithms (Random Forest, Gradient Boosting, Decision Tree, Linear Regression) for predicting barley yields in Morocco. Includes complete data pipeline from preprocessing to model evaluation. Built with Python and scikit-learn.
# 🌾 Barley Yield Prediction Using Machine Learning (Synthetic Educational Project)
This project demonstrates how machine learning can be applied to predict **barley yields** using synthetic but realistic agronomic data inspired by Moroccan farming systems.
> ⚠️ **Disclaimer:** The data used here is fully synthetic and intended for educational and demonstration purposes only. Do not use it for operational agricultural decisions.
---
## Project Summary
This repository provides a full ML pipeline to simulate precision agriculture applications, specifically for barley yield prediction, using realistic input variables:
- **Environmental conditions** (temperature, rainfall, soil pH)
- **Soil nutrients** (N, P, K, organic matter)
- **Farm management** (fertilizer rates, seed density, crop variety)
- **Geographical context** (regions, soil types)
**Goal**: Showcase how data science can support data-driven decision-making in dryland agriculture.
---
## Key Features
- End-to-end pipeline: data cleaning → feature engineering → ML modeling
- Comparative analysis of 4 ML models
- Explainable AI: Feature importance analysis & interpretability
- Modular codebase ready for real-world adaptation
- Structured for clarity and reproducibility
---
## Dataset Overview
Synthetic dataset with **1500 observations** and realistic ranges for Moroccan agronomy.
### Categorical Features
| Feature | Description | Sample Values |
|----------------|----------------------------------|------------------------------------------|
| `region` | Barley production region | Chaouia, Fès-Boulemane, Gharb, etc. |
| `soil_type` | Soil classification | Vertisol, Clay, Loam, Sandy |
| `barley_variety`| Barley cultivar used | Khnata, Assiya, Amira, Chifaa, Massine |
### Numerical Features
| Feature | Unit | Description | …