The forecast was made from the 14 days before this date only. The weather shown is what that day actually had; the scene above clears or turns hazy with the real AQI.
Kolkata's air follows a strong yearly rhythm: smoggy from November to February, clean through the monsoon. The GRU learned that rhythm from 2018 to 2026. Starting from the latest official value (CPCB's daily bulletin), it forecasts one day, feeds that forecast back in, and keeps going, using Open-Meteo's weather forecast for the next two weeks and the average weather of each calendar day after that. This is an outlook, not live data, and the shaded range shows how far off this method was when we tested it on 2025 to 2026.
The models were trained on 2018 to 2023 and chosen on 2024, then tested once on these days. Persistence ("tomorrow equals today") is the baseline to beat.
The project explained step by step: what it does, where the data comes from, which algorithms we used and why, the maths behind them, the hardware, and the results. Choose a tab.
Every winter Kolkata's air turns "Poor" or worse for weeks at a time. A forecast one day ahead gives people time to act: keep children indoors, skip a morning run, plan around the worst days.
We forecast tomorrow's official AQI (India's National AQI from CPCB, the 24-hour value published at 4 PM) from the previous 14 days of air-quality and weather data, and raise a high-pollution alert when the forecast is above 200 ("Poor" or worse).
We compared eight forecasters, from linear regression to Transformers, against the simplest forecast, persistence ("tomorrow will be like today"). A model only counts as better when a statistical test says so. The chosen model, a GRU neural network, now runs this website every day.
It is not unsupervised learning (there are labels) and not reinforcement learning (no agent or reward).
| Source | What we took | Used as |
|---|---|---|
| CPCB CCR portal, AQI repository | Official daily city AQI for Kolkata, 4 PM bulletin, 2018 to 2026 | The forecast target |
| CPCB CCR portal, CAAQMS repository | 24-hour readings of 11 pollutants (PM2.5, PM10, NO, NO2, NOx, NH3, CO, SO2, O3, benzene, toluene) from 7 WBPCB stations: Ballygunge, Bidhannagar, Fort William, Jadavpur, Rabindra Bharati University, Rabindra Sarobar, Victoria | Pollution inputs |
| Open-Meteo historical weather | 12 daily variables for central Kolkata: temperature (mean, max, min), rain, rain hours, wind (max, mean, direction), sunlight, humidity, dew point, pressure | Weather inputs |
| NASA FIRMS, VIIRS S-NPP | Vegetation fire detections in 82 to 92 E, 20 to 28 N, summarised per day | Fire inputs |
| Festival calendar | Kali Puja, Durga Puja, Holi, New Year, and the 2020 lockdown | Event inputs |
| Kaggle, Air Quality Data in India | Kolkata rows of city_day.csv, 2018 to 2020 | First stage of the project |
| CPCB daily bulletins, data.gov.in, Open-Meteo forecast | New official AQI each evening, live station sub-indices, tomorrow's weather | This website's live parts |
Neighbouring days are very similar. A random split would put days from the "future" into training and make every model look better than it is. The scaler (mean and spread of each input) is also learned from the training years only.
Download CPCB city AQI and the 7 station files, Open-Meteo weather, NASA fire detections and the festival calendar.
Join everything by date into 2,953 rows, apply the cleaning rules and log every decision.
Each sample is the previous 14 days of inputs, labelled with the next day's AQI. Windows only look backwards.
Train, validation and test are blocks of dates. Scaling uses training statistics only.
8 forecasters x 3 input sets (pollution; plus weather; plus fires and festivals). Neural networks use 3 seeds each.
The lowest mean validation error wins. All choices are saved to disk before the test years are touched.
Score 2025 to 2026 once, against persistence on the same days, with a 95% block-bootstrap interval.
Repeat the whole procedure with 2022, 2023 and 2024 as test years, each trained only on earlier data.
Every evening, a scheduled job reads CPCB's new bulletin and Open-Meteo's weather, the GRU rolls the outlook forward, and the site republishes.
| Algorithm | Family | How it works | Why we used it |
|---|---|---|---|
| Persistence | Baseline | Tomorrow's AQI = today's AQI | The bar every model must beat; hard to beat because air changes slowly |
| Ridge regression | Linear model | A weighted sum of all inputs, with an L2 penalty on the weights | The simplest learned model; shows whether deep learning is needed at all |
| Random forest | Tree ensemble (bagging) | Averages many decision trees, each trained on a bootstrap sample | Captures non-linear effects with no scaling and little tuning |
| XGBoost | Gradient-boosted trees | Adds trees one at a time, each correcting the errors of the ones before | The strongest classic method on tabular data |
| GRU | Recurrent neural network | Reads the 14 days in order and keeps a memory, controlled by an update gate and a reset gate | Built for sequences; fewer parameters than an LSTM, which suits about 2,000 training days |
| LSTM | Recurrent neural network | A memory cell with input, forget and output gates | The classic sequence model; strong long-range memory |
| Attention LSTM | RNN with attention | An LSTM that learns a weight for each of the 14 days | Interpretable: shows which past days the forecast relied on |
| TCN | Temporal convolutional network | Dilated 1-D convolutions that are causal (only look backwards) | A fast, parallel alternative to recurrent networks |
| Transformer | Self-attention | Every day in the window attends to every other day | The state of the art for sequences; tests whether attention alone is enough |
| Ensemble | Model averaging | The mean of the GRU, LSTM, Transformer and XGBoost forecasts | Different models make different errors, which partly cancel |
| Quantile attention LSTM | Quantile regression | Predicts the 10th, 50th and 90th percentiles with the pinball loss | Gives a range of likely values, not just one number |
| GRU classifier | Binary classification | Outputs the probability that tomorrow's AQI is above 200 | A calibrated alert, with the threshold chosen on validation |
The LSTM (pollution only) scored lower on test (11.2), but picking it after seeing the test results would be cheating, so we report it without choosing it.
xt is the vector of inputs on day t, and θ the weights learned in training.
σ is the sigmoid and ⊙ element-wise multiplication. The term zt ⊙ ht−1 is an additive path that lets memory and gradients pass through many days, which eases the vanishing gradient problem.
Four weight sets against the GRU's three: about 25% more parameters for the same hidden size.
gt is the gradient from backpropagation through time; m̂ and v̂ are the bias-corrected averages. Gradients are clipped to norm 1.0.
Under-forecasting costs τ per point and over-forecasting costs 1 − τ, so the minimiser is the τ-th percentile. The 10th and 90th percentiles give the 80% range. The network is built so the three can never cross.
The test days are resampled in blocks of 7 consecutive days, 2,000 times, and Δ is recomputed each time. The 2.5th to 97.5th percentiles give the 95% interval. Blocks keep the day-to-day correlation that a plain bootstrap would break. A model counts as better only if the whole interval is below zero.
Cp is the 24-hour concentration of pollutant p, and Blo, Bhi are the breakpoints of its band. At least 3 pollutants are needed, one of them PM2.5 or PM10. The live "Government AQI now" averages this over Kolkata's stations.
| Test year | Persistence | GRU | Ensemble |
|---|---|---|---|
| 2022 | 18.6 | 14.6 | 14.2 |
| 2023 | 19.5 | 15.1 | 14.9 |
| 2024 | 17.0 | 13.4 | 13.1 |
| 2025 to 2026 | 13.8 | 11.8 | 10.9 |
| All 1,764 days | baseline | −3.2 [−4.0, −2.4] | −3.8 [−4.5, −3.0] |
MAE in AQI points. Both models beat persistence with 95% confidence in every year.
| Years of training data | Samples | Test MAE |
|---|---|---|
| 1 | 365 | 14.9 (worse than persistence) |
| 2 | 729 | 12.0 |
| 3 | 1,094 | 11.7 |
| 5 | 1,822 | 11.8 |
On the Kaggle data (747 days) plain ridge regression won. With four times more official data, the neural networks lead.
| Days ahead | Model MAE | Persistence | Difference [95%] |
|---|---|---|---|
| 1 | 11.8 | 13.8 | −2.0 [−3.2, −0.7] |
| 3 | 19.9 | 22.2 | −2.2 [−4.3, −0.1] |
| 7 | 22.4 | 25.2 | −2.8 [−6.0, −0.2] |
Training runs in PyTorch's deterministic GPU mode, so the same machine gives the same numbers on every run. Everything also runs on a CPU, just slower.
The main experiment trains 24 model combinations, most with 3 seeds, plus learning curves, multi-day horizons and four walk-forward rounds: hundreds of networks. The GPU runs the matrix operations of each training batch in parallel, which made the whole study take minutes instead of hours. For a single forecast the GRU is tiny, so the live site needs no GPU.
Neighbouring days are very similar, so a random split lets the model see days around each test day during training. That leaks the future and inflates the score. We split by date: train up to 2023, validate on 2024, test on 2025 to 2026.
Air quality changes slowly, so "tomorrow equals today" is already a strong forecast. A model is only useful if it beats this free forecast, and we only claim it does when the 95% interval of the difference is entirely below zero.
We did not pick by taste. Every model was scored on the 2024 validation year and the GRU had the lowest error. It also has two gates instead of three, about 25% fewer weights, which helps with only about 2,000 training days.
A small model (32 units, 1 layer), dropout 0.2, weight decay, early stopping on validation loss (patience 20), gradient clipping, choosing settings on validation only, and averaging 3 seeds.
On an average test day the forecast was 11.8 AQI points away from the official value. Persistence was 13.8 points away, so the GRU's error is about 14% lower.
In a plain RNN the gradient is multiplied by the same weights at every time step, so it shrinks towards zero and the network forgets early days. The GRU's update gate gives an additive path, ht = (1 − z)·n + z·ht−1, so information and gradients can flow across many days.
The network is unrolled over the 14 days like a 14-layer network with shared weights. The loss gradient is passed back through every day, and the gradients for the shared weights are added up.
It was fixed before any experiment. Two weeks covers two weekly cycles and the multi-day weather spells (calm, dry, cold air) that trap pollution in Kolkata's winter.
A little for the GRU (12.2 to 11.8), but for most models the difference was not statistically clear. Yesterday's AQI already carries much of the weather's effect.
A neural network's result depends on its random starting weights. Training with seeds 42, 43 and 44 and averaging makes the forecast stable, and shows that a result is not luck.
November is when pollution rises fastest, so every method does worse: persistence was 28.1 over the same days. The live model also uses fewer inputs, because station pollutant files are not available every evening.
We use India's National AQI from CPCB: a 24-hour average with Indian breakpoints. Many apps show the US AQI or an hourly reading, which uses a different formula and time window, so they give different numbers for the same air.
The test years have cleaner air than most training years. Settings were chosen once, on 2024, and reused in every walk-forward round. Weather and fires show associations, not causes. Only two stations reported in 2018.