| title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned |
|---|---|---|---|---|---|---|---|
Kaduna Agricultural Forecasting |
🌾 |
green |
yellow |
streamlit |
1.25.0 |
app.py |
false |
This system provides advanced time-series forecasting for crop production in Kaduna State to support food security planning and policy decisions. It implements a three-tier modeling strategy using Statistical (ARIMA/SARIMAX), Machine Learning (XGBoost), and Deep Learning (LSTM/GRU) models.
- Multi-Model Forecasting: Compare performance of ARIMA, SARIMAX, XGBoost, LSTM, and GRU models.
- Automated Feature Engineering: Generates yield, lag features, rolling statistics, and trend indicators.
- Policy Recommendations: Automatically detects shortage/oversupply risks and suggests policy actions.
- Interactive Visualizations: Generates Plotly charts for forecasts and model comparisons.
- Comprehensive Evaluation: Uses RMSE, MAE, MAPE, and R² to evaluate model accuracy.
- Clone the repository.
- Install dependencies:
pip install -r requirements.txt
To train all models and generate a 3-year forecast for Maize:
python main.py --crop Maize --model all --train --forecast-years 3--data: Path to dataset CSV (default:Kaduna_State_Agricultural_Production_Data.csv)--crop: Crop name to forecast (e.g., "Maize", "Sugar cane", "Rice")--model: Model to use (arima,sarimax,xgboost,lstm,gru, orall)--train: Flag to retrain models--forecast-years: Number of years to forecast (default: 3)
Results are saved in the outputs/ directory:
outputs/models/: Saved trained modelsoutputs/predictions/: Forecast CSV filesoutputs/visualizations/: Interactive plots (HTML) and static charts (PNG)outputs/: Policy briefs (TXT) and model comparison tables (CSV)
To launch the user-friendly web interface:
-
Install Streamlit:
pip install streamlit
-
Run the app:
streamlit run app.py
The dashboard allows you to:
- Select any crop and model
- Adjust forecast horizons
- View interactive charts
- Download policy briefs
KadPred/
├── src/
│ ├── models/ # Model implementations (ARIMA, XGBoost, LSTM, etc.)
│ ├── data_loader.py # Data loading and cleaning
│ ├── feature_engineering.py # Feature creation
│ ├── evaluation.py # Metrics and comparison
│ ├── visualization.py # Plotting utilities
│ ├── predictor.py # Forecasting pipeline
│ └── policy_advisor.py # Policy recommendation logic
├── outputs/ # Generated results
├── main.py # Main execution script
└── requirements.txt # Dependencies
The system analyzes forecasts against a 5-year historical baseline:
- Shortage Risk: Production < 20% of baseline (Action: Release reserves, Import)
- Oversupply Risk: Production > 20% of baseline (Action: Storage, Export)
- Normal: Within ±10% of baseline (Action: Maintain support)