Machine learning models (Random Forest, XGBoost, Feedforward Neural Network) for predicting N₂O emissions from Sub-Saharan African soils across forest, cropland, and grassland land-use types.
# N2O Emissions Prediction Models - Open Access
This repository contains three machine learning models for predicting N2O emissions from different land use types (Forest, Cropland, Grassland) using environmental and management variables.
## Models Included
1. **Random Forest Model** (`random_forest_n2o_model.py`)
2. **Artificial Neural Network Model** (`artificial_neural_network_n2o_model.py`)
3. **XGBoost Model** (`xgboost_n2o_model.py`)
## Author
**P. Agredazywczuk**
Date: 20245-05-22
Modified for open access: 2026
## Requirements
### Python Dependencies
```bash
# Core packages
pandas>=1.3.0
numpy>=1.21.0
scikit-learn>=1.0.0
matplotlib>=3.3.0
seaborn>=0.11.0
scipy>=1.7.0
# Model-specific packages
tensorflow>=2.8.0 # For Neural Network model
xgboost>=1.5.0 # For XGBoost model
joblib>=1.0.0 # For model saving/loading
```
### Installation
```bash
pip install pandas numpy scikit-learn matplotlib seaborn scipy tensorflow xgboost joblib
```
## Data Requirements
### Input Data Format
Your input data should be a CSV file with the following columns:
#### Required for all land use types:
- `date`: Date of measurement (YYYY-MM-DD format)
- `lat`: Latitude
- `lon`: Longitude
- `site`: Site identifier
- `landuse`: Land use type ('Forest', 'Cropland', 'Grassland', 'Wetland Forest')
- `fert`: Fertilisation treatment indicator
- `temp`: Air temperature (°C)
- `tmax`: Maximum air temperature (°C)
- `tmin`: Minimum air temperature (°C)
- `rain`: Precipitation (mm)
- `soil_moisture_1`: Soil moisture at depth 1 (m³/m³)
- `soil_moisture_2`: Soil moisture at depth 2 (m³/m³)
- `soil_moisture_3`: Soil moisture at depth 3 (m³/m³)
- `soil_temp_1`: Soil temperature at depth 1 (°C)
- `soil_temp_2`: Soil temperature at depth 2 (°C)
- `soil_temp_3`: Soil temperature at depth 3 (°C)
- `ccov`: Cloud cover (fraction)
- `vpd`: Vapor pressure deficit (kPa)
- `ssrd`: Surface solar radiation downwards (MJ/m²)
- `ppfd`: Photosynthetic photon flux density (μmol/m²/s)
- `days_si …