← All projects

Machine-learning case study · Lahore

Next-day PM2.5 regression

Pakistan Air Quality Intelligence

A reproducible model that estimates Lahore’s next-day PM2.5 from recent pollution, weather and seasonal features.

Final estimator
Histogram gradient boosting
Training data
1,636 model-ready days
Validation
5 chronological folds

StateAir Lahore OpenAQ location 8664 · sensor 25135

Historical model replay

Predict the following day

µg/m³
Available model-ready dates: 30 May 2019–17 February 2025.
Forecast for 18 February 2025 165.04 Predicted PM2.5 concentration
Current
143.00
Predicted change
+22.04
Observed next day
227.00
Absolute error
61.96
Recent PM2.5 historyObserved Forecast Actual next day
250 0
19 January 202518 February 2025

Historical replay from the final fitted model. Out-of-sample performance is reported through chronological validation below.

Cross-validated MAE32.16 µg/m³
Persistence baseline34.48 µg/m³
Average improvement6.54%
Folds beating baseline5/5
Modelling period2019–2025

Chronological evaluation

Performance tested on future time windows

The model was evaluated with five expanding time-series folds. Each training window occurred before its test window, preventing future information from leaking into earlier predictions.

Enhanced model
32.16 MAE
Persistence rule
34.48 MAE
Mean absolute error by foldEnhanced model Baseline
Fold 1
25.1526.63
5.54% better
Fold 2
32.0333.81
5.26% better
Fold 3
37.5741.71
9.92% better
Fold 4
33.0034.28
3.74% better
Fold 5
33.0435.99
8.22% better

Data and modelling evidence

What the model actually learned from

01 · Sources

Measured pollution and weather

  • OpenAQ StateAir Lahore daily PM2.5
  • NASA POWER temperature, humidity, wind and precipitation
  • Station coordinates: 31.560078° N, 74.335890° E
02 · Preparation

Conservative missing-data treatment

  • 2,113 calendar days audited
  • Only gaps of three days or fewer interpolated
  • 46 values filled; 305 longer-gap values remained missing
03 · Features

Twenty time-aware predictors

  • PM2.5 lags, rolling means and variability
  • Weather levels, changes and precipitation totals
  • Pollution momentum and annual seasonality
Model development resultsAverage chronological MAE · lower is better
Persistence baseline34.48
Random Forest33.20
Change model32.34
Enhanced gradient boosting32.16

Machine-learning pipeline

From observations to tomorrow’s estimate

The final estimator predicts the next-day change, which is added to the current PM2.5 concentration.

  1. 01
    Acquire

    OpenAQ PM2.5 and NASA POWER weather

  2. 02
    Engineer

    Lags, rolling means, momentum and seasonality

  3. 03
    Learn ΔPM2.5

    Gradient boosting with absolute-error loss

  4. 04
    Validate forward

    Five expanding chronological test windows

  5. 05
    Forecast

    Current value + predicted change = tomorrow

Prediction logic

PMt+1 = PMt + f(xt)

f estimates the next-day change from the feature vector at day t
Estimator
HistGradientBoostingRegressor
Loss
Absolute error
Learning rate
0.05
Iterations
300
Maximum leaf nodes
15
Training rows
1,636

Responsible interpretation

Research prototype, not a public-health alert

Appropriate use

Educational analysis, reproducible experimentation and short-horizon forecasting research.

Current limitations

One monitoring station, long missing periods, no traffic, crop-burning, dust or satellite aerosol indicators.

Next development

Multiple monitors, satellite variables, prediction intervals and scheduled data ingestion.

Reproducible project

Inspect the code and validation evidence

Python scripts cover acquisition, feature engineering, training, evaluation and historical prediction export.