# Machine Learning Based Maize Yield Classification in Southwestern Nigeria
The selected model is an extended Random Forest. The following independent test results were produced by the pipeline fitted on the 120 development observations:
| Measure | Value |
| --- | ---: |
| Accuracy | 0.667 |
| Macro precision | 0.672 |
| Macro recall | 0.671 |
| Macro F1 | 0.663 |
| Macro one versus rest ROC AUC | 0.713 |
| Macro average precision | 0.638 |
The climate fields are complete April through October summaries. Application outputs are therefore retrospective end of season classifications, not early season forecasts.
## Run on Windows
1. Extract the ZIP and open the `maize_yield_prediction` folder in VS Code.
2. Open a PowerShell terminal in that folder.
3. Create and activate an environment:
```powershell
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
```
4. Run the tests:
```powershell
python -m pytest -q
```
5. Start the application:
```powershell
python -m streamlit run app.py
```
6. Open the local address shown in the terminal, normally `
localhost`.
## Run on macOS or Linux
```bash
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
python -m pytest -q
python -m streamlit run app.py
```
## Inputs and units
| Column | Meaning | Unit |
| --- | --- | --- |
| `nitrogen` | iSDAsoil total topsoil nitrogen | g/kg |
| `phosphorus` | iSDAsoil extractable topsoil phosphorus | ppm |
| `potassium` | iSDAsoil extractable topsoil potassium | ppm |
| `temperature` | April through October mean air temperature | degrees Celsius |
| `humidity` | April through October mean relative humidity | percent |
| `soil_ph` | Topsoil pH | pH units |
| `rainfall` | April through October precipitation total | mm |
| `state` …