Built to order

AI-Based Air Quality Forecasting using LSTM and OpenAQ Data

This project builds an AI system that forecasts the Air Quality Index for Indian cities up to 72 hours ahead, using a two-layer LSTM trained on hourly pollutant data from the OpenAQ open-data platform. It converts pollutant forecasts into AQI values with the CPCB National AQI bands and presents them on a dashboard with city selection, pollutant charts and a three-day forecast table. The report documents the pipeline from API fetch to evaluation against a persistence baseline. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.

Chat on WhatsApp — get a quotation

AI & Machine Learning PythonFlaskMatplotlibJupyter notebookTensorFlow · Keraspandas · NumPyHTML · CSS · JavaScriptOpenAQ v3 APISoftware
AI-Based Air Quality Forecasting using LSTM and OpenAQ Data — project thumbnail preview
More project photos (2)

The problem

AI-Based Air Quality Forecasting using LSTM and OpenAQ Data builds a forecasting system that predicts the Air Quality Index for Indian cities up to 72 hours ahead, learning from hourly pollutant measurements pulled from the OpenAQ open-data platform. The system trains a two-layer LSTM on seven days of PM2.5, PM10, NO2, SO2, CO and O3 readings, then converts pollutant forecasts into AQI values using the CPCB National AQI bands, with CPCB band labels. Most air-quality apps only report today's reading, leaving residents and schools guessing about tomorrow; this project closes that gap with a genuine multi-day forecast and a dashboard showing the expected band for each of the next three days. Because the data comes from OpenAQ's open API, the pipeline is reproducible for any city with monitoring stations. Builder note (demo build, illustrative series): the Delhi view shows AQI 185 (Moderate band) with PM2.5 at 148 µg/m³ — nearly 5 times the CPCB Good-band ceiling of 30 µg/m³.

SYSTEM FLOW

5 components 4 connections

Live flow
Drag to explore
100%
storageOpenAQ v3 API

Hourly PM2.5, PM10, NO2, SO2, CO and O3 from government reference stations, via a free API key.

Follow the working sequence

How it works

End to end, this is a data pipeline with a model in the middle: OpenAQ measurements flow in, are cleaned and windowed, pass through the LSTM, come out as pollutant forecasts, are converted to AQI, and land on the dashboard as charts and tables. It starts by querying the OpenAQ v3 API for the city's monitoring locations and downloading hourly measurements for six pollutants over the past 7 days. Cleaning interpolates gaps up to 3 hours, drops longer gaps, clips outliers to the CPCB breakpoint range, and aligns timestamps to IST. The cleaned series is sliced into 168-hour input windows of 1,008 values each (6 pollutants × 168 hours), and the two-layer LSTM learns to predict the next 72 hourly AQI values. At inference time the latest window feeds the saved model, its outputs map through the CPCB sub-index formula, the highest sub-index becomes the AQI, and the dashboard renders the forecast curve, daily band table and pollutant snapshot.

  1. The OpenAQ v3 API is queried for the selected city's locations, and the sensors for PM2.5, PM10, NO2, SO2, CO and O3 are listed.
  2. Hourly measurements for the past 7 days are downloaded per sensor and stored as one timestamped table per city.
  3. The data is cleaned: gaps of up to 3 hours are interpolated, longer gaps are dropped, outliers are clipped to the CPCB breakpoint range, and timestamps are aligned to IST.
  4. Cleaned series are sliced into 168-hour input windows (6 pollutants × 168 hours = 1,008 values per window) with the following 72 hourly AQI values as targets.
  5. The two-layer LSTM (64 + 32 hidden units, dropout 0.2) is trained on these windows with Adam and mean squared error loss, holding out the last 7 days for testing.
  6. The trained model is evaluated on the held-out week: RMSE and MAE per horizon, compared against the 24-hour persistence baseline.
  7. At inference time the latest 168-hour window is fed to the saved model, pollutant forecasts are converted to AQI with the CPCB sub-index formula, and the dashboard renders the 72-hour curve, daily band table and pollutant snapshot.

Tech stack:

  • Python 3

  • TensorFlow · Keras (LSTM model)

  • OpenAQ v3 API (air-quality data)

  • Pandas · NumPy (data pipeline)

  • Flask (dashboard backend)

  • HTML · CSS · JavaScript (dashboard)

  • Matplotlib (training & evaluation plots)

  • Jupyter Notebook (training & evaluation)

  • Dataset: OpenAQ open air-quality data via the v3 API — hourly measurements from government reference monitoring stations (including CPCB stations in India), covering PM2.5, PM10, NO2, SO2, CO and O3; a free API key is required and the build fetches the most recent 7 days per city for 6 Indian cities.

  • Task: Time-series regression; input = 168 hours of hourly readings across 6 pollutants (1,008 values), output = the next 72 hourly AQI values, each mapped to one of the 6 CPCB AQI bands (Good, Satisfactory, Moderate, Poor, Very Poor, Severe).

  • Model: Two-layer LSTM (64 + 32 hidden units, dropout 0.2, sequence-to-one with a 72-step rollout), trained with Adam and mean squared error loss; the persistence baseline (24-hour lag) is evaluated alongside for an honest comparison.

  • Metrics: RMSE and MAE per forecast horizon (24 h, 48 h, 72 h), plus per-city error tables; development target RMSE ≤ 18 AQI at the 72-hour horizon. No accuracy is claimed as measured until the training run is executed for the order.

Parameter Value
Forecast horizon 72 hours (24 h and 48 h views also available)
Input window 168 hours of hourly readings (7 days)
Pollutants 6 pollutants (PM2.5, PM10, NO2, SO2, CO, O3)
Cities in demo 6 cities (Delhi, Mumbai, Pune, Bengaluru, Chennai, Kolkata)
Model Two-layer LSTM, 64 + 32 hidden units, dropout 0.2
Forecast error RMSE ≤ 18 AQI at 72 h (design target, not a measured claim)
Training time Approximately 20–40 min on a laptop CPU (expected)
Inference Under 1 second per city forecast on CPU (expected)
Data source OpenAQ v3 API (free API key required)
AQI bands CPCB National AQI, 6 bands from Good 0–50 to Severe 401–500
Demo Single-file web dashboard, runs offline after download

Project features

The strongest capabilities of this build are its genuine 72-hour LSTM forecast, its honest open-data pipeline, and its CPCB-correct AQI presentation. The forecast is a real sequence model, not a trend line: a two-layer LSTM reads 168 hours of hourly readings across 6 pollutants and predicts the next 72 hourly AQI values, so the dashboard shows tomorrow and the day after, not just today. The data pipeline is equally real: measurements come from the OpenAQ v3 API, which aggregates government reference monitors, and every fetch, cleaning step and window is code the student can show and explain. Finally, the presentation follows the CPCB National AQI bands exactly — Good 0–50 through Severe 401–500 — with a daily forecast table, pollutant charts and a persistence baseline, so the model must earn its place by beating the simple rule that tomorrow equals today.

  • [72-hour LSTM forecast] A two-layer LSTM (64 + 32 hidden units, dropout 0.2) reads a 168-hour window of hourly readings and predicts AQI for the next 72 hours, shown as an hourly curve and a daily summary table.
  • [OpenAQ v3 data pipeline] Measurements for PM2.5, PM10, NO2, SO2, CO and O3 are fetched from the OpenAQ v3 API (locations → sensors → measurements) with a free API key, cleaned, gap-filled and aligned to IST.
  • [CPCB AQI conversion] Pollutant forecasts are converted to AQI with the CPCB sub-index formula, and the highest sub-index becomes the AQI; every value is coloured by its CPCB band from Good to Severe.
  • [Multi-city dashboard] A working dashboard covers 6 Indian cities — Delhi, Mumbai, Pune, Bengaluru, Chennai and Kolkata — with a city selector, a 24/48/72-hour horizon selector and per-pollutant views.
  • [Persistence baseline] Every forecast is scored against a 24-hour persistence baseline ("tomorrow equals today"), so the report shows honestly whether the LSTM adds value.
  • [Forecast evaluation notebook] RMSE and MAE are computed per horizon in a documented Jupyter notebook, with training curves and per-city error tables for the report.
  • [Health-band guidance] Each forecast day carries plain-language guidance tied to its CPCB band, such as reduced prolonged outdoor exertion on Poor days.

What is included

  • Complete LSTM training & evaluation Jupyter notebook
  • OpenAQ v3 data pipeline code (fetch, clean, window, convert to AQI)
  • Working multi-city forecast dashboard (city selector, horizon selector, pollutant charts, daily forecast table)
  • Trained model file with the inference script
  • RMSE/MAE evaluation tables and training-curve plots
  • Project report PDF (background, LSTM theory, OpenAQ API, methodology, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (LSTM memory, AQI bands, OpenAQ API, baselines)

Limitations & prerequisites

  • Forecast quality depends on station coverage: a city with few or offline OpenAQ stations has thin or gappy input data, and gaps longer than 3 hours are dropped rather than invented.
  • The 72-hour RMSE ≤ 18 AQI figure is a design target for the training run, stated honestly — the report documents the actual achieved figure after training.
  • AQI is computed with the CPCB formula from forecast pollutants; it is an academic estimate, not an official CPCB bulletin and not a substitute for CPCB or SAFAR forecasts.
  • The model predicts from past pollutant history only; it does not ingest weather, wind or stubble-burning data, so sudden weather-driven changes can surprise it.
  • The demo dashboard ships with an illustrative series shaped to typical Indian-city ranges; live forecasts need a free OpenAQ API key and an internet connection.
  • OpenAQ v3 requires a free API key, and the free tier has request limits, so the pipeline caches fetched data rather than calling the API on every page load.
  • Winter inversion episodes can push AQI beyond the training range, and the model has no mechanism to extrapolate beyond what it has seen.

Frequently Asked Questions

Which data source is used, and is it real data?

OpenAQ is a real open air-quality platform: its v3 API aggregates hourly measurements from government reference monitors, including CPCB stations in India, and this project fetches PM2.5, PM10, NO2, SO2, CO and O3 through it with a free API key. The demo dashboard ships with an illustrative series shaped to typical Indian-city ranges so it runs offline, and the report states this clearly. Connecting live data needs only the key and an internet connection.

Which model is used, and why LSTM?

A two-layer LSTM with 64 + 32 hidden units and dropout 0.2, because air quality has memory — today's smog is partly yesterday's smog — and the LSTM's 168-hour input window covers seven full daily traffic cycles. The report also evaluates a 24-hour persistence baseline, so the LSTM must beat the simple rule that tomorrow equals today. Training uses Adam with mean squared error loss on 168-hour windows.

How accurate is the forecast?

No accuracy is claimed as measured, and no figure in this listing is a test result. The development target is an RMSE of 18 AQI or better at the 72-hour horizon, and the report documents the figure the team's own training run actually achieves, per horizon and per city. Forecast quality also depends on station coverage in the chosen city, and the limitations section states the failure modes honestly.

Can I add my own city?

Yes, if the city has OpenAQ stations. Adding a city means registering its locations through the v3 API, fetching its sensors, and retraining or fine-tuning the model on that city's history — the pipeline code is written per city, so this is a configuration change plus a training run. Cities with no monitoring stations cannot be forecast from real data.

Does the dashboard need internet?

The demo dashboard runs offline after download, because it ships with an illustrative series shaped to typical Indian-city ranges. Live forecasts need internet and a free OpenAQ API key, since the pipeline fetches the latest seven days of hourly measurements and runs the saved model. The fetch code caches results so repeated views do not hit the API rate limits.

Is this project suitable for a final-year project?

Yes — for Computer Science, IT and AI & Machine Learning programs, because it demonstrates time-series deep learning with a real open API, honest evaluation against a baseline, and a working multi-city dashboard that a student can operate live in the viva. The report explains the LSTM design, the CPCB AQI conversion and the data pipeline in viva-ready detail.

Components & software requirements
  • Python 3
  • TensorFlow · Keras (LSTM model)
  • OpenAQ v3 API (air-quality data)
  • Pandas · NumPy (data pipeline)
  • Flask (dashboard backend)
  • HTML · CSS · JavaScript (dashboard)
  • Matplotlib (training & evaluation plots)
  • Jupyter Notebook (training & evaluation)
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Get a quotation