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.
The Fire Weather Index (FWI) is a numeric rating of fire intensity. This project:
- Loads and preprocesses the Algerian Forest Fires dataset
- Removes highly correlated features (threshold: 0.85)
- Scales features using
StandardScaler - Trains and evaluates four regression models with cross-validated hyperparameters
- Produces visualisations for correlation analysis, scaling effects, and model comparison
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, andyearare dropped as they are not used as predictive features.
.
├── 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
Prerequisites: Python 3.9 or higher
-
Clone or download this repository.
-
(Recommended) Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Place
Algerian_forest_fires_dataset_cleaned.csvinside thedata/directory.
Run the training script:
python3 models/train_model.pyThe 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/, includingfeatures.jsonfor the Flask app
| 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.
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.