Machine learning web app to predict the Fire Weather Index (FWI) for Algerian forest fire datasets β built with Flask, Ridge/Lasso/ElasticNet/Linear regression models, and a fire-themed UI.
# π₯ FWI Predictor
Machine-learning powered Fire Weather Index (FWI) prediction web app built with Flask.
## Project Structure
```
fwi_app/
βββ app.py # Flask application
βββ wsgi.py # Gunicorn entry point
βββ requirements.txt # Python dependencies
βββ Procfile # Heroku / Railway / Render
βββ Models/
β βββ ridge_model.pkl # Trained Ridge Regression model
β βββ scaler.pkl # Fitted StandardScaler
βββ templates/
βββ index.html # Landing page
βββ home.html # Prediction form + results
```
## Run Locally
```bash
pip install -r requirements.txt
python app.py
# β
localhost
```
## Deploy
### Render (free tier)
1. Push to GitHub
2. New Web Service β connect repo
3. Build: `pip install -r requirements.txt`
4. Start: `gunicorn wsgi:application`
### Railway
```bash
railway init
railway up
```
### Heroku
```bash
heroku create fwi-predictor
git push heroku main
```
## REST API
POST `/api/predict` with JSON body:
```json
{
"Temperature": 29,
"RH": 57,
"Ws": 18,
"Rain": 0,
"FFMC": 85.9,
"DMC": 26.2,
"ISI": 5.1,
"Classes": 0,
"Region": 0
}
```
Response:
```json
{
"fwi": 42.15,
"risk_level": "High",
"description": "High fire potential. Avoid outdoor burning."
}
```
## FWI Risk Levels
| FWI Range | Level |
|-----------|-----------|
| < 15 | Low |
| 15 β 29 | Moderate |
| 30 β 44 | High |
| 45 β 64 | Very High |
| β₯ 65 | Extreme |