vantage/
← projects

Machine Learning · 2026 · complete

SIWES Oil Spill Risk Classifier

Severity classifier for Niger Delta oil spills built on NOSDRA incident records. Three XGBoost setups were compared on a 96%-Minor dataset; class weighting won on macro F1 and minority recall, at a large cost in precision.

Specs

Source
NOSDRA Oil Spill Monitor
Raw data
21,107 rows x 42 cols
Usable
13,202 rows (Unknown severity dropped)
Split
10,561 train / 2,641 test, stratified 80/20
Class balance
Minor 96.0% / Medium 3.6% / Major 0.4%
Final model
Class-weighted XGBoost (lr=0.1, depth=7, 100 trees)
Macro F1
0.420 (baseline 0.346, SMOTENC 0.371)
Medium recall
0.40 (baseline 0.03, SMOTENC 0.08)
Major recall
0.20, i.e. 2 of 10 test cases
Precision
0.12 for both Major and Medium
Accuracy
86.6% (baseline 95.9%)

Features

  • -Predicts spill severity (Minor / Medium / Major) from 9 incident features available at reporting time
  • -Streamlit app: enter an incident profile, get a severity assessment from the class-weighted model
  • -Severity label engineered from NOSDRA barrel thresholds and habitat type
  • -Honest imbalance study: unweighted baseline vs SMOTENC (inside a CV pipeline) vs class weighting
  • -Five executed notebooks, one per CRISP-DM phase, plus reusable src/ modules

Architecture & tech stack

  1. 01 IngestNOSDRA CSV, placed in data/raw/ (not tracked in git).
  2. 02 PreprocessDrop 34 columns (>20% missing, IDs, free text); extract year and month; label-encode categoricals; engineer the severity target.
  3. 03 SplitStratified 80/20 with random_state=42. The test set holds only 10 Major cases, so Major metrics are indicative.
  4. 04 ImbalanceBaseline vs SMOTENC (capped at 600 rows per minority class, resampled on training folds only) vs balanced sample weights.
  5. 05 SelectClass-weighted XGBoost chosen on macro F1 and minority recall; weighted F1 is ignored because the Dummy classifier scores 0.94 on it.
  6. 06 ExplainSHAP TreeExplainer to be re-run on the final weighted model; earlier driver findings are marked unverified in the README.
  7. 07 Servestreamlit_app.py loads models/xgboost_weighted_model.pkl and the saved encoders.
Pythonpandasscikit-learnXGBoostGridSearchCVimbalanced-learn (SMOTENC)SHAPStreamlit

Known limitations

  • !Major and Medium precision are both about 0.12: roughly 8 in 9 high-severity flags are false alarms. Recall was prioritised on purpose, because a needless investigation visit costs less than missing a serious spill.
  • !SMOTENC barely helped (Medium recall 0.03 to 0.08, Major stayed 0.00). Nine features that cannot observe spill volume cap what any resampling can recover.
  • !The model is a screening aid, not a decision-maker. Severity is derived from reported volume, so noise in that field carries into the target.
  • !SHAP driver findings (cause, habitat, company, year) still need re-verifying against the final model, and results come from a single split.

Local development guide

1. Get the code
$ git clone https://github.com/shalombebx/oil-spill-risk-classifier.git
$ cd oil-spill-risk-classifier
2. Virtual environment and dependencies
$ python -m venv venv
$ source venv/bin/activate # Windows: venv\Scripts\activate
$ pip install -r requirements.txt
3. Add the dataset
# Not in the repo. Download from nosdra.oilspillmonitor.ng
$ cp ~/Downloads/nosdra_*_complete.csv data/raw/
4. Reproduce the pipeline
# Run notebooks 01 -> 05 in order; each depends on the last
$ jupyter notebook notebooks/
5. Launch the app
# Needs models/xgboost_weighted_model.pkl and label_encoders.pkl (from notebooks 03-04)
$ streamlit run streamlit_app.py