I wanted a next-day AQI predictor for Pune. Then Diwali got close and I got more curious about how wrong it would be than how right. A model trained on ordinary days only knows ordinary days, so on the days it doesn't know about, the size of its mistake is a rough measurement of what the festival adds.
That was the idea. Here's what actually came out of it, including the parts that made my first version of this post look worse.
The headline R²
With a random 80/20 split I get R² 0.86, which matches the notebook. But yesterday's AQI is the top feature (0.38 importance, then PM2.5 at 0.22), so I checked the dumbest possible baseline: "tomorrow's AQI = today's AQI" scores 0.84 on the same test rows — the model barely beats it.
The random split is also leaky, since neighbouring days land on both sides of it. So I split by time instead: train on the first 80% of days, test on the rest (roughly late October onwards, into winter, with higher AQI than anything the model had seen).
| Model | R² | MAE |
|---|---|---|
| Random forest | −0.82 | 5.2 |
| Tomorrow = today | 0.40 | 18.2 |
One year can't teach a model what winter looks like. That's the real limitation here.
What I trained on
Hourly CO, NO₂, ozone, PM10, PM2.5 and SO₂ readings for Pune from 31 Dec 2023 to 31 Dec 2024, plus daily city AQI values. NH₃ got dropped (too many gaps). I threw away every hour with any missing value (8,010 rows → 6,437) and collapsed them into daily medians. Features are today's pollutants, today's AQI, month and weekday. Target is tomorrow's AQI. Random forest, 300 trees, max depth 5, min 4 samples per leaf.
How wrong is it on Diwali?
Diwali started on 24 Oct that year, and the air agrees: median PM2.5 went from 38 to 141 overnight. I held out rows from 23 Oct to 6 Nov 2024 out of training and looked at the misses (actual minus predicted):
| Day | Actual | Predicted | Miss |
|---|---|---|---|
| 24 Oct | 125 | 62 | +63 |
| 02 Nov | 208 | 115 | +93 |
The model is fine for the days in between, because once AQI is up, yesterday's AQI tells it so. It can't see the jumps coming: the start of the festival on 24 Oct, and the night of 1 Nov into 2 Nov, when AQI went from 114 to 208.
On the other 333 days the miss averages +0.1 with a standard deviation of 16.3, and 95% of them are under 36 points. The biggest ordinary-day miss is +54. Both festival jumps are bigger than that, and the 2 Nov miss is about 5.7 standard deviations out — two festival jumps do tell something that single ordinary misses don't.
What I'd do next
An is_diwali_week feature would fix this one case and say nothing about why, but it would at least stop the model being surprised twice a year. And the one-year data problem is solvable: the AQI-only file has 2,345 days back to Nov 2017, so I can ask the same question for several Diwalis instead of one.