Task: Binary classification to detect oil spill presence from tabular data
About Dataset The dataset was developed by starting with satellite images of the ocean, some of which contain an oil spill and some that do not. Images were split into sections and processed using computer vision algorithms to provide a vector of features to describe the contents of the image section or patch. The task is, given a vector that describes the contents of a patch of a satellite image, then predicts whether the patch contains an oil spill or not, e.g. from the illegal or accidental dumping of oil in the ocean.
There are two classes and the goal is to distinguish between spill and non-spill using the features for a given ocean patch.
Non-Spill: negative case, or majority class. Oil Spill: positive case, or minority class.
https://www.kaggle.com/datasets/sudhanshu2198/oil-spill-detection/data
This project aims to detect oil spills using a neural network on a small, imbalanced dataset.
The workflow covers a full ML pipeline:
- Data loading and inspection
- Data preprocessing (scaling, removing constant features)
- Stratified train/validation/test split
- Handling class imbalance using class weights
- Neural network model building and training
- Threshold tuning to maximize F1 score for the minority class
- Evaluation using confusion matrix, classification report, and ROC/AUC
- Samples: 937
- Features: 50 (after dropping constant columns)
- Target:
0= no oil spill,1= oil spill - Highly imbalanced, with very few positive (spill) cases
- Input layer: 50 features
- Dense layers: 64 → 32 → 16 neurons with ReLU activation
- BatchNormalization + Dropout (0.3) for regularization
- Output layer: 1 neuron, sigmoid activation
- Optimizer: Adam, learning rate 1e-3
- Loss: Binary crossentropy
- Class weights applied to address imbalance
-
Test Accuracy: 95.7% (high due to the majority class)
-
Oil Spill Class (minority, 1):
- Recall: 0.83 → model correctly detects most spills (5 out of 6)
- Precision: 0.50 → some false alarms occur
- F1-score: 0.625 → reasonable balance between precision and recall
-
Non-Spill Class (majority, 0):
- Precision & Recall: >0.96 → almost all non-spill cases are correctly predicted
-
Optimal Threshold: 0.44 (instead of default 0.5) to improve minority class recall
Observations:
- The model detects most oil spills, which is crucial for safety-critical applications.
- Some false positives are expected due to the small and imbalanced dataset.
- Overall, the performance is realistic and acceptable given the data limitations.
The notebook includes:
- Confusion matrix
- ROC curve
- Training/validation loss and accuracy curves
These visualizations help evaluate the model performance for both majority and minority classes.
- Clone the repository:
git clone <repo-url>- Install dependencies
pip install -r requirements.txtOpen the Jupyter Notebook notebooks/OilSpill_Classification.ipynb
Update the dataset path if needed
Run all cells sequentially to reproduce results