| 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) |
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.
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
- Overview
- Features
- Demo
- Installation
- Usage
- Input Parameters
- Risk Levels
- Technical Details
- Project Structure
- Contributing
- License
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.
- 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
Try the live demo on Hugging Face Spaces: Forest Fire Prediction Demo
- Python 3.8 or higher
- pip package manager
# 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- Access the web interface at
http://localhost:7861 - Input environmental parameters using the sliders
- Select the region and fire class
- Click "Predict Fire Weather Index"
- Review the prediction, risk level, and recommendations
| 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) |
- Regular monitoring recommended
- Standard fire prevention measures
- Suitable for controlled burns
- Enhanced monitoring required
- Increased vigilance needed
- Review of fire response procedures
- Immediate precautions necessary
- Constant monitoring required
- Emergency response team standby
-
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:
- Input Validation: Range-based checks for all parameters
- Feature Preprocessing: StandardScaler transformation
- Prediction: Ridge Regression model
- Post-processing: Risk level classification and recommendations
-
Performance Metrics:
- Cross-validation: 5-fold CV
- Evaluation metrics: MAE, Rยฒ Score
- Model persistence using pickle serialization
- 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
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
- Dhananjay Nerkar - GitHub
- 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
Dhananjay Nerkar - nerkarr.dhananjay@gmail.com Project Link: https://github.com/dhananjaynerkar/forest-fire-prediction