CoolFace
Apppublic

kavinda0126/coral-reef-bleaching-prediction

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿชธ Coral Reef Bleaching Risk Predictor

A machine learning web application that predicts coral reef bleaching risk using four trained classification models. Built as part of an ML assignment at SLIIT.

Overview

Coral bleaching occurs when ocean temperatures rise above normal levels, causing corals to expel their symbiotic algae and turn white. This app takes real-world oceanographic measurements as input and predicts whether a reef site is at risk of bleaching.

Dataset: Global Coral Bleaching Database 1980โ€“2020 (BCO-DMO)


Models

ModelTest AccuracyF1 ScoreROC-AUCScaling
Logistic Regression67.39%0.68350.7338Yes
Random Forest90.45%0.90800.9704No
XGBoost90.21%0.90490.9683No
SVM (RBF Kernel)87.89%0.88170.9285Yes

All four models vote on the final prediction. The consensus is determined by the number of models predicting bleaching:

  • โ€”4/4 votes โ†’ CRITICAL
  • โ€”3/4 votes โ†’ HIGH RISK
  • โ€”2/4 votes โ†’ MODERATE
  • โ€”1/4 votes โ†’ LOW RISK
  • โ€”0/4 votes โ†’ SAFE

Input Features

FeatureDescription
ClimSSTClimatological Sea Surface Temperature (ยฐC)
Temperature_MeanMean SST (ยฐC)
Temperature_MinimumMinimum SST (ยฐC)
Temperature_MaximumMaximum SST (ยฐC)
SSTASea Surface Temperature Anomaly (ยฐC)
SSTA_DHWSST Anomaly Degree Heating Weeks
TSAThermal Stress Anomaly (ยฐC)
TSA_DHWThermal Stress Anomaly DHW
TSA_DHW_FrequencyFrequency of TSA DHW events
WindspeedWind speed (m/s)
SSTA_FrequencyFrequency of positive SSTA
SSTA_Frequency_Standard_DeviationStd dev of SSTA frequency
Turbidity_ctTurbidity count
TurbidityWater turbidity
Cyclone_FrequencyFrequency of cyclone events
DistanceDistance to nearest land (km)
DepthReef depth (m)
Latitude_DegreesLatitude
Longitude_DegreesLongitude
Date_YearYear of observation

Key bleaching risk indicators:

  • โ€”TSA_DHW > 8 โ†’ severe bleaching expected
  • โ€”Temperature_Mean > 30ยฐC + SSTA > 1.5 โ†’ high risk
  • โ€”Low turbidity + high DHW โ†’ maximum risk

App Features

Single Prediction

Adjust ocean condition sliders to get an instant prediction from all 4 models with a probability bar chart and consensus gauge.

Sample Reef Sites

Load pre-configured data from 10 real-world reef locations including the Great Barrier Reef, Maldives, Red Sea, and Caribbean.

Batch Prediction

Run all 10 sample sites through all 4 models simultaneously and view results as a probability heatmap.

Model Info

View loaded model performance metrics (accuracy, F1, ROC-AUC) and feature counts.


Project Structure

โ”œโ”€โ”€ app.py                    # Gradio web application
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ lr/                   # Logistic Regression artifacts
โ”‚   โ”‚   โ”œโ”€โ”€ lr_model.pkl
โ”‚   โ”‚   โ”œโ”€โ”€ lr_scaler.pkl
โ”‚   โ”‚   โ”œโ”€โ”€ lr_features.pkl
โ”‚   โ”‚   โ””โ”€โ”€ lr_metadata.json
โ”‚   โ”œโ”€โ”€ rf/                   # Random Forest artifacts
โ”‚   โ”œโ”€โ”€ xgb/                  # XGBoost artifacts
โ”‚   โ””โ”€โ”€ svm/                  # SVM artifacts
โ””โ”€โ”€ notebooks/                # Training notebooks

Local Setup

bash
pip install -r requirements.txt
python app.py

Tech Stack

  • โ€”ML: scikit-learn, XGBoost
  • โ€”UI: Gradio
  • โ€”Data: pandas, numpy
  • โ€”Visualization: matplotlib