Painting of Kolkata's riverside: the Howrah Bridge over the Hooghly, a tram, a yellow taxi and a hand-pulled rickshaw, with the Victoria Memorial in the distance
Kolkata AQI ForecastNeural Networks and Deep Learning · IEM Kolkata
Actual AQI–
Loading…
–GRU forecast
–Ensemble forecast
–GRU error
1 Jan 2025Drag through 669 days and watch the sky change31 Oct 2026
Scroll
The chosen day

Forecast vs reality

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.

Real air quality
–
0100200300400500
White marker: actual. Orange marker: GRU forecast.
What the models forecast
In brackets: forecast minus actual.
Weather that day
Future outlook · from today to December 2027

The year ahead, from the patterns of the last eight

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.

Actual AQI (official CPCB) Outlook Old outlook from 31 Oct, vs real November 80% range
Click any point to open that day. The dashed line marks the last real data.
Test period · 1 Jan 2025 to 31 Oct 2026

669 days the model never saw

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.

Click any point to open that day
Actual AQI GRU forecast Ensemble forecast Persistence 80% range
High-pollution days (actual AQI above 200)
How we built it

From raw data to a forecast

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.

Days of official data
2,953
1 Oct 2018 to 31 Oct 2026
Models compared
24
8 forecasters x 3 input sets
Test days, scored once
669
1 Jan 2025 to 31 Oct 2026
GRU vs persistence
11.8 vs 13.8 MAE
14% lower error, significant

What is this project?

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.

What kind of learning is this?

  • Supervised learning. Every training example is a 14-day window of inputs labelled with the real AQI of the next day.
  • Regression, on a time series. The output is a number (the AQI), and the inputs are ordered in time.
  • Quantile regression. A second network predicts the 10th, 50th and 90th percentiles, which gives the 80% range.
  • Binary classification. A GRU classifier gives the probability that tomorrow's AQI is above 200.
  • Offline (batch) training. Models are trained on past data, then used. They do not keep learning while the site runs.
  • Deep learning. Recurrent networks (GRU, LSTM), attention, temporal convolutions and Transformers, trained by backpropagation through time.

It is not unsupervised learning (there are labels) and not reinforcement learning (no agent or reward).

Where the data comes from

SourceWhat we tookUsed as
CPCB CCR portal, AQI repositoryOfficial daily city AQI for Kolkata, 4 PM bulletin, 2018 to 2026The forecast target
CPCB CCR portal, CAAQMS repository24-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, VictoriaPollution inputs
Open-Meteo historical weather12 daily variables for central Kolkata: temperature (mean, max, min), rain, rain hours, wind (max, mean, direction), sunlight, humidity, dew point, pressureWeather inputs
NASA FIRMS, VIIRS S-NPPVegetation fire detections in 82 to 92 E, 20 to 28 N, summarised per dayFire inputs
Festival calendarKali Puja, Durga Puja, Holi, New Year, and the 2020 lockdownEvent inputs
Kaggle, Air Quality Data in IndiaKolkata rows of city_day.csv, 2018 to 2020First stage of the project
CPCB daily bulletins, data.gov.in, Open-Meteo forecastNew official AQI each evening, live station sub-indices, tomorrow's weatherThis website's live parts

Cleaning rules

  • The target is never filled in. The 4 days without an official AQI are never used as forecast targets.
  • Pollutant inputs are the daily mean over the stations reporting that day.
  • Input gaps of at most 7 days are carried forward and flagged. Longer gaps are not invented.
  • Boundary layer height was dropped: it is missing for January to June 2024, the validation year.
  • Low-confidence fires are dropped. We use the log count of fires within 300 km and the log fire power in the region.
  • Raw files are never modified. The tests check their bytes.

Split by date, never at random

Train
1 Oct 2018 to 31 Dec 2023 · 1,918 days
Validation
all of 2024 · 366 days
Test
1 Jan 2025 to 31 Oct 2026 · 669 days

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.

Step 1

Collect

Download CPCB city AQI and the 7 station files, Open-Meteo weather, NASA fire detections and the festival calendar.

Step 2

One daily table

Join everything by date into 2,953 rows, apply the cleaning rules and log every decision.

Step 3

14-day windows

Each sample is the previous 14 days of inputs, labelled with the next day's AQI. Windows only look backwards.

Step 4

Split and scale

Train, validation and test are blocks of dates. Scaling uses training statistics only.

Step 5

Train 24 models

8 forecasters x 3 input sets (pollution; plus weather; plus fires and festivals). Neural networks use 3 seeds each.

Step 6

Choose on 2024

The lowest mean validation error wins. All choices are saved to disk before the test years are touched.

Step 7

Test once

Score 2025 to 2026 once, against persistence on the same days, with a 95% block-bootstrap interval.

Step 8

Walk forward

Repeat the whole procedure with 2022, 2023 and 2024 as test years, each trained only on earlier data.

Step 9

Go live

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.

The forecasters we compared

AlgorithmFamilyHow it worksWhy we used it
PersistenceBaselineTomorrow's AQI = today's AQIThe bar every model must beat; hard to beat because air changes slowly
Ridge regressionLinear modelA weighted sum of all inputs, with an L2 penalty on the weightsThe simplest learned model; shows whether deep learning is needed at all
Random forestTree ensemble (bagging)Averages many decision trees, each trained on a bootstrap sampleCaptures non-linear effects with no scaling and little tuning
XGBoostGradient-boosted treesAdds trees one at a time, each correcting the errors of the ones beforeThe strongest classic method on tabular data
GRURecurrent neural networkReads the 14 days in order and keeps a memory, controlled by an update gate and a reset gateBuilt for sequences; fewer parameters than an LSTM, which suits about 2,000 training days
LSTMRecurrent neural networkA memory cell with input, forget and output gatesThe classic sequence model; strong long-range memory
Attention LSTMRNN with attentionAn LSTM that learns a weight for each of the 14 daysInterpretable: shows which past days the forecast relied on
TCNTemporal convolutional networkDilated 1-D convolutions that are causal (only look backwards)A fast, parallel alternative to recurrent networks
TransformerSelf-attentionEvery day in the window attends to every other dayThe state of the art for sequences; tests whether attention alone is enough
EnsembleModel averagingThe mean of the GRU, LSTM, Transformer and XGBoost forecastsDifferent models make different errors, which partly cancel
Quantile attention LSTMQuantile regressionPredicts the 10th, 50th and 90th percentiles with the pinball lossGives a range of likely values, not just one number
GRU classifierBinary classificationOutputs the probability that tomorrow's AQI is above 200A calibrated alert, with the threshold chosen on validation

Why the GRU was chosen

  • By rule, not by hindsight. It had the lowest validation error on 2024 (MAE 12.9) of all 24 combinations, decided before the test years were seen.
  • Right size for the data. Two gates instead of the LSTM's three means about 25% fewer weights, so less overfitting on 1,918 training days.
  • Small and fast. 32 hidden units in one layer: it trains in seconds on the GPU and is light enough to run in plain NumPy for the live site.
  • Best alert. On the test years it had the best high-pollution alert score (F1 0.723 vs 0.585 for persistence) and R² 0.919.

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.

GRU training settings

Input
14 days x (AQI, 11 pollutants, weather, day of year)
Hidden units, layers
32, 1
Dropout
0.2 before the output layer
Loss
Mean squared error
Optimiser
Adam, learning rate 0.001
Weight decay
0.00001
Batch size
32
Epochs
up to 200, early stopping after 20 without improvement
Gradient clipping
norm 1.0
Seeds
42, 43, 44, forecasts averaged

The forecasting problem

ŷt+1 = fθ(xt−13, xt−12, …, xt)

xt is the vector of inputs on day t, and θ the weights learned in training.

Persistence:  ŷt+1 = yt
Change mode:  ŷt+1 = yt + Δ̂,   where the model predicts Δ = yt+1 − yt
Scaling:  x′ = (x − μtrain) / σtrain

GRU cell (as in PyTorch)

rt = σ(Wrxt + Urht−1 + br)   reset gate
zt = σ(Wzxt + Uzht−1 + bz)   update gate
nt = tanh(Wnxt + rt ⊙ (Unht−1 + bhn) + bn)
ht = (1 − zt) ⊙ nt + zt ⊙ ht−1
ŷ = wᵀ h14 + b

σ 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.

LSTM cell, for comparison

ft, it, ot = σ(W xt + U ht−1 + b)   forget, input, output gates
ct = ft ⊙ ct−1 + it ⊙ tanh(Wcxt + Ucht−1 + bc)
ht = ot ⊙ tanh(ct)

Four weight sets against the GRU's three: about 25% more parameters for the same hidden size.

Training: loss and optimiser

L(θ) = (1/N) Σi (yi − ŷi)² + λ‖θ‖²
mt = β1mt−1 + (1 − β1) gt,   vt = β2vt−1 + (1 − β2) gt²
θ ← θ − η · m̂t / (√v̂t + ε)   Adam, η = 0.001

gt is the gradient from backpropagation through time; m̂ and v̂ are the bias-corrected averages. Gradients are clipped to norm 1.0.

Forecast range: pinball loss

Lτ(y, q) = max( τ(y − q), (τ − 1)(y − q) ),   τ ∈ {0.1, 0.5, 0.9}

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.

How we score

MAE = (1/N) Σ |yi − ŷi|    RMSE = √( (1/N) Σ (yi − ŷi)² )
R² = 1 − Σ (yi − ŷi)² / Σ (yi − ȳ)²
Precision = TP / (TP + FP),   Recall = TP / (TP + FN),   F1 = 2PR / (P + R)
Ensemble:  ŷ = ¼ (ŷGRU + ŷLSTM + ŷTransformer + ŷXGBoost)

Is the difference real? Block bootstrap

Δ = MAEmodel − MAEpersistence

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.

How CPCB computes the AQI

Ip = (Ihi − Ilo) / (Bhi − Blo) · (Cp − Blo) + Ilo
AQI = maxp Ip

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 MAE
11.8 vs 13.8
GRU vs persistence, 669 days
Difference [95%]
−2.0 [−3.2, −0.7]
The whole interval is below zero
Alert F1 (AQI above 200)
0.723 vs 0.585
GRU vs persistence
80% range coverage
92%
of test days fell inside the range

Walk-forward test: does it hold in other years?

Test yearPersistenceGRUEnsemble
202218.614.614.2
202319.515.114.9
202417.013.413.1
2025 to 202613.811.810.9
All 1,764 daysbaseline−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.

More data is what mattered

Years of training dataSamplesTest MAE
136514.9 (worse than persistence)
272912.0
31,09411.7
51,82211.8

On the Kaggle data (747 days) plain ridge regression won. With four times more official data, the neural networks lead.

Forecasting further ahead

Days aheadModel MAEPersistenceDifference [95%]
111.813.8−2.0 [−3.2, −0.7]
319.922.2−2.2 [−4.3, −0.1]
722.425.2−2.8 [−6.0, −0.2]

On this website, in the real world

  • The live GRU uses inputs available every evening (AQI, weather, day of year): test MAE 12.9 vs 13.8 for persistence.
  • 1 to 24 November 2026, against CPCB's real bulletins: day-ahead MAE 23.4 vs 28.1 for persistence. November is the hardest month, when winter pollution builds up quickly.
  • The rolling outlook beat the seasonal average at every horizon from 1 day to a year when back-tested on 2025 to 2026.

Hardware

Machine
Lenovo Legion Pro 7i Gen 10 laptop
GPU
NVIDIA GeForce RTX 5070 Ti, 12 GB
CPU
Intel Core Ultra 9
Memory
64 GB DDR5
Main experiment
about 36 min on the GPU
Walk-forward test
about 13 min

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.

Software

Language
Python 3.13
Deep learning
PyTorch 2.15, CUDA 13.2
Classic models
scikit-learn, XGBoost
Data
pandas, NumPy
Figures
Matplotlib
Tests
unittest, research-rule checks

This website

Page
HTML, CSS, JavaScript, Chart.js
Hosting
Cloudflare Pages
Live government AQI
Cloudflare function, data.gov.in API
Daily update
GitHub Actions, 5:45 PM every day
Model on the server
GRU weights exported to NumPy

Why a GPU?

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.

Why not split the data at random?

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.

Why compare against persistence?

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.

Why a GRU and not an LSTM?

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.

How did you prevent overfitting?

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.

What does MAE 11.8 mean?

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.

What is the vanishing gradient problem, and how does the GRU help?

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.

What is backpropagation through time?

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.

Why 14 days of history?

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.

Did weather, fires and festivals help?

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.

Why use several seeds?

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.

Why is the error in November 2026 (23.4) higher than on the test years (11.8)?

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.

Why does this site show a different AQI from weather apps?

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.

What are the limitations?

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.