An AI-powered web app that predicts and visualizes wildfire risk across Ontario based on user-uploaded weather data.
- Upload a
.csvfile containing weather data for Ontario stations. - A machine learning model predicts wildfire occurrence tiers (Low / Moderate / High / Extreme) for the next month.
- Results are visualized on an interactive Leaflet map with color-coded markers and a visible legend:
- ๐ข Low Risk โ Fewer than 50 fires โ Routine local response
- ๐ก Moderate โ 50โ150 fires โ Regional resource prep
- ๐ High โ 150โ300 fires โ Full deployment
- ๐ด Extreme โ Over 300 fires โ National/international coordination
- Each marker includes a GPT-generated explanation and prevention tip.
| Tool/Library | Usage |
|---|---|
๐ง scikit-learn |
ML model (Random Forest Regressor) |
| โ๏ธ FastAPI (Python) | Backend API |
| ๐ React + Tailwind | Frontend web app |
| ๐บ๏ธ React-Leaflet | Interactive maps |
| ๐ค OpenAI GPT | Natural language fire risk summaries |
| โ๏ธ Vercel + Render | Frontend and backend hosting |
```mermaid graph TD A[User Uploads CSV] --> B[FastAPI Backend] B --> C[ML Model (.pkl)] C --> D[Predicted Fire Count] D --> E[Frontend Receives Prediction] E --> F[Animated Number Display] E --> G[Map Color Update] G --> H[CircleMarker Color & Tooltip] ```
forest-fire-predictor/
โโโ ml-model/
โ โโโ train_model.py
โ โโโ merge_weather_fire.py
โ โโโ forest_fire_merged.pkl
โ โโโ fire_counts_clean.csv
โโโ web-app/
โ โโโ frontend/ # React + Tailwind + Leaflet
โ โโโ backend/ # FastAPI
โ โโโ main.py
โ โโโ model_loader.py
โ โโโ requirements.txt
โโโ README.md
cd web-app/backend
pip install -r requirements.txt
uvicorn main:app --reloadcd web-app/frontend
npm install
npm run devSet
.envinfrontend/:
VITE_API_URL=http://localhost:8000Station,TempMax,TempMin,TempMean,Precipitation,CoolingDegreeDays
Pickle Lake,32,5,18,65,45
Red Lake,30,6,17,70,50
Sioux Lookout,33,4,19,80,60Each row = 1 Ontario station ๐ Output = wildfire tier + natural language explanation
โThis location is at high risk due to elevated temperatures (34ยฐC), low humidity, and low rainfall. Avoid open flames and clear dry brush near your property.โ
-
Leaflet map renders all Ontario fire stations
-
CircleMarkers color-coded by predicted fire count:
- ๐ข 0โ49
- ๐ก 50โ99
- ๐ 100โ149
- ๐ด 150+
-
Hover tooltip shows station name + predicted fire count
-
Legend explains color scale
-
Smooth color fade transitions using CSS
Trained with a Random Forest Regressor to predict monthly fire counts from historical weather.
| Feature | Description |
|---|---|
| Tm | Mean Temperature (ยฐC) |
| Tx | Max Temperature (ยฐC) |
| Tn | Min Temperature (ยฐC) |
| S | Rainfall (mm) |
| P | Precipitation (mm) |
| CDD | Cooling Degree Days |
| Month | Weather month number |
| Year | Year of record |
A fire count (rounded) โ Mapped to Risk Tier:
| Risk Tier | Fires per Month | Response Level |
|---|---|---|
| ๐ข Low | 0โ49 | Routine local response |
| ๐ก Moderate | 50โ150 | Pre-position regional resources |
| ๐ High | 150โ300 | Full deployment |
| ๐ด Extreme | Over 300 | National/international assistance |
import pandas as pd
import pickle
# Load model
with open("forest_fire_model_aggregated.pkl", "rb") as f:
model = pickle.load(f)
# Predict
X_new = pd.DataFrame([{
"Tm": 17.5,
"Tx": 32.0,
"Tn": 3.0,
"S": 0.0,
"P": 60.0,
"CDD": 25.0,
"Weather_Month_Num": 6,
"Year": 2024
}])
y_pred = model.predict(X_new)
print("Predicted fires:", y_pred)โ๏ธ Core pipeline complete:
- โ Cleaned weather + fire count datasets (2000โ2023)
- โ Merged and aggregated per station per month
- โ Trained ML model on aggregated dataset
- โ Backend integration and prediction API
- โ CSV upload + file parsing working
- โ Map color visualization and tooltips
- Animated splash loader (~1.5s)
- Prediction button disables on click
- RingLoader spinner during model run
- Fire count animates from 0 to predicted value
- ๐ Integrate live weather APIs (e.g., OpenWeatherMap)
- ๐ฐ๏ธ Add satellite/vegetation data
- ๐ Monthly model retraining
- ๐ Add dashboard for trend analysis
- Frontend: https://fire-predict.vercel.app](#)
| Member |
|---|
| Madison Zhang |
| Tenzing Woser |
| Preethi Kamalakkannan |