Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algerian Forest Fires — FWI Prediction

A regression-based machine learning project that predicts the Fire Weather Index (FWI) using meteorological and fire-index features from the Algerian Forest Fires dataset. Four regression models are trained, tuned, and compared.


Table of Contents


Overview

The Fire Weather Index (FWI) is a numeric rating of fire intensity. This project:

  1. Loads and preprocesses the Algerian Forest Fires dataset
  2. Removes highly correlated features (threshold: 0.85)
  3. Scales features using StandardScaler
  4. Trains and evaluates four regression models with cross-validated hyperparameters
  5. Produces visualisations for correlation analysis, scaling effects, and model comparison

Dataset

File: Algerian_forest_fires_dataset_cleaned.csv

The dataset covers two regions of Algeria (Bejaia and Si-Bel-Abbes) and contains daily weather observations and fire index components. The cleaned version used here has had null values and formatting issues resolved.

Feature Description
Temperature Noon temperature (°C)
RH Relative Humidity (%)
Ws Wind speed (km/h)
Rain Total rainfall (mm)
FFMC Fine Fuel Moisture Code
DMC Duff Moisture Code
DC Drought Code
ISI Initial Spread Index
BUI Buildup Index
FWI Fire Weather Index (target)

The columns day, month, and year are dropped as they are not used as predictive features.


Project Structure

.
├── app.py                                      # Flask prediction app
├── data/
│   └── Algerian_forest_fires_dataset_cleaned.csv
├── models/
│   └── train_model.py                         # Main training script
├── src/                                       # Saved scaler, models, and feature list
├── static/                                    # Frontend assets
├── templates/                                 # Flask templates
├── requirements.txt                           # Python dependencies
└── README.md

Setup

Prerequisites: Python 3.9 or higher

  1. Clone or download this repository.

  2. (Recommended) Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate        # macOS/Linux
    venv\Scripts\activate           # Windows
  3. Install dependencies:

    pip install -r requirements.txt
  4. Place Algerian_forest_fires_dataset_cleaned.csv inside the data/ directory.


Usage

Run the training script:

python3 models/train_model.py

The script will:

  • Print MSE, RMSE, and R² for each model to the console
  • Display the best cross-validated hyperparameters for Ridge, Lasso, and ElasticNet
  • Show a series of plots (correlation heatmap, scaling comparison, model comparison charts)
  • Save trained artifacts in src/, including features.json for the Flask app

Models

Model Hyperparameter Tuning
Linear Regression None
Ridge Regression alpha selected via 5-fold CV from [0.1, 1.0, 10.0]
Lasso Regression alpha selected via 5-fold CV from [0.1, 1.0, 10.0]
ElasticNet Regression alpha and l1_ratio selected via 5-fold CV

Regularisation hyperparameters are tuned automatically using scikit-learn's RidgeCV, LassoCV, and ElasticNetCV — no separate grid search step is needed.


Results

After training, a summary table is printed to the console sorted by R², and two comparison charts are displayed:

  • RMSE bar chart — lower is better
  • All-metrics grouped bar chart — MSE, RMSE, and R² side by side

These make it straightforward to pick the best-performing model for this dataset.

About

Predicts the Fire Weather Index (FWI) from Algerian meteorological data using four regression models — Linear, Ridge, Lasso, and ElasticNet — with cross-validated hyperparameter tuning, feature correlation filtering, and standardised scaling for end-to-end wildfire risk prediction.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages