Skip to content

Latest commit

ย 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

title Forest Fire Prediction
emoji ๐Ÿ“š
colorFrom indigo
colorTo gray
sdk gradio
sdk_version 5.25.2
app_file app.py
pinned false
license mit
short_description Predict forest fire risk using Fire Weather Index (FWI)

Forest Fire Prediction

About

A Gradio regression application that estimates the Fire Weather Index from environmental inputs and maps the result to fire-risk guidance. The repository includes a Ridge-based model workflow and a Hugging Face Spaces configuration; evaluation is dataset- and split-specific.

Hugging Face Spaces Python Gradio scikit-learn NumPy Pandas License


Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

๐Ÿ“‹ Table of Contents

๐ŸŒŸ Overview

This machine learning-based system predicts the Fire Weather Index (FWI) in forest areas using meteorological and environmental factors. It provides real-time risk assessment and recommendations for fire prevention and management.

โœจ Features

  • Real-time Predictions: Instant FWI calculations
  • Interactive Interface: User-friendly web interface with intuitive controls
  • Risk Assessment: Three-level risk classification system
  • Smart Recommendations: Contextual advice based on risk levels
  • Input Validation: Comprehensive parameter validation
  • Visual Feedback: Color-coded results and clear visual indicators

๐ŸŽฎ Demo

Try the live demo on Hugging Face Spaces: Forest Fire Prediction Demo

Demo Screenshot Demo Screenshot Demo Screenshot

๐Ÿš€ Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Setup Steps

# Clone the repository
git clone https://github.com/dhananjaynerkar/forest-fire-prediction.git
cd forest-fire-prediction

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows

# Install dependencies
pip install -r requirements.txt

# Run the application
python app.py

๐Ÿ’ป Usage

  1. Access the web interface at http://localhost:7861
  2. Input environmental parameters using the sliders
  3. Select the region and fire class
  4. Click "Predict Fire Weather Index"
  5. Review the prediction, risk level, and recommendations

๐Ÿ“Š Input Parameters

Parameter Range Description
Temperature 22-42ยฐC Ambient temperature
Relative Humidity 21-90% Air humidity percentage
Wind Speed 6-29 km/h Wind velocity
Rain 0-16.8 mm Rainfall amount
FFMC 28.6-92.5 Fine Fuel Moisture Code
DMC 1.1-65.9 Duff Moisture Code
ISI 0-18.5 Initial Spread Index
Classes 0 or 1 Fire occurrence (0: No, 1: Yes)
Region 0 or 1 Location (0: Bejaia, 1: Sidi-Bel Abbes)

๐ŸŽฏ Risk Levels

Low Risk (0-10)

  • Regular monitoring recommended
  • Standard fire prevention measures
  • Suitable for controlled burns

Moderate Risk (11-20)

  • Enhanced monitoring required
  • Increased vigilance needed
  • Review of fire response procedures

High Risk (>20)

  • Immediate precautions necessary
  • Constant monitoring required
  • Emergency response team standby

๐Ÿ”ง Technical Details

Model Architecture

  • Algorithm: Ridge Regression with Cross-Validation (RidgeCV)

    • Selected for its robust performance with continuous target variables
    • Handles multicollinearity in weather-related features
    • Reported checkpoint: Rยฒ 0.9843 and MAE 0.5642 on a 61-row holdout; this small-sample result is not a production generalization guarantee.
  • Feature Engineering:

    • Input features correlation analysis (threshold: 0.85)
    • Removed highly correlated features to prevent multicollinearity
    • Feature scaling using StandardScaler
    • Normalized numerical features to [0,1] range
  • Model Pipeline:

    1. Input Validation: Range-based checks for all parameters
    2. Feature Preprocessing: StandardScaler transformation
    3. Prediction: Ridge Regression model
    4. Post-processing: Risk level classification and recommendations
  • Performance Metrics:

    • Cross-validation: 5-fold CV
    • Evaluation metrics: MAE, Rยฒ Score
    • Model persistence using pickle serialization

Technologies Used

  • Backend: Python, scikit-learn
  • Frontend: Gradio 5.25.2+
  • Data Processing: NumPy, Pandas
  • Model Serialization: Pickle
  • Deployment: Hugging Face Spaces
  • Version Control: Git LFS for model files

๐Ÿ“ Project Structure

forest-fire-prediction/
โ”‚
โ”œโ”€โ”€ app.py                 # Main application file
โ”œโ”€โ”€ dataset/              # Dataset directory
โ”‚   โ””โ”€โ”€ Algerian_forest_fires_cleaned_dataset.csv
โ”œโ”€โ”€ models/               # Model directory
โ”‚   โ”œโ”€โ”€ ridge.pkl         # Trained model
โ”‚   โ””โ”€โ”€ scaler.pkl        # Fitted scaler
โ”œโ”€โ”€ notebooks/            # Jupyter notebooks
โ”‚   โ”œโ”€โ”€ EDA And FE Algerian Forest Fires.ipynb
โ”‚   โ””โ”€โ”€ Model Training.ipynb
โ”œโ”€โ”€ venv/                 # Virtual environment
โ”œโ”€โ”€ .env                  # Environment variables
โ”œโ”€โ”€ .env.example          # Environment variables template
โ”œโ”€โ”€ .gitattributes        # Git LFS configuration
โ”œโ”€โ”€ .gitignore           # Git ignore rules
โ”œโ”€โ”€ demo1.PNG             # Demo screenshots
โ”œโ”€โ”€ demo2.PNG
โ”œโ”€โ”€ demo3.PNG
โ”œโ”€โ”€ deploy.py             # Deployment script
โ””โ”€โ”€ requirements.txt     # Dependencies

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.

๐Ÿ‘ฅ Authors

๐Ÿ™ Acknowledgments

  • UCI Machine Learning Repository for providing the Algerian Forest Fires Dataset
  • The research paper: "Predicting Forest Fire in Algeria using Data Mining Techniques: Case Study of the Decision Tree Algorithm" by Faroudja ABID et al.
  • Hugging Face for hosting the demo application
  • Gradio team for the excellent UI framework
  • All contributors and reviewers who helped improve this project

๐Ÿ“ง Contact

Dhananjay Nerkar - nerkarr.dhananjay@gmail.com Project Link: https://github.com/dhananjaynerkar/forest-fire-prediction

About

Gradio regression application that estimates Fire Weather Index from environmental inputs and maps the result to fire-risk guidance.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages