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 |