Skip to main content

Air Quality Classification

空気質分類Course project
Air Quality Classification screenshot
Decision tree & random forest: 17/17 correct on the held-out test set

The data is a real-time snapshot of 85 stations from the Ministry of Environment's Air Quality Index (AQI) open data, predicting the air-quality category from six pollutants: PM2.5, PM10, O3, CO, SO2 and NO2. The whole workflow was built visually in Orange — unsupervised clustering on the left, a comparison of five classifiers on the right.

The Chinese version of this page has a live demo with real data. Open it (in Chinese) →

Problem

Using six pollutant readings from the Ministry of Environment's open air-quality data (PM2.5, PM10, O3, CO, SO2, NO2), predict the air-quality category at 85 stations across Taiwan and compare how different classifiers perform.

Key decisions

  1. 01

    Stratified 80/20 split with a fixed random seed

    Each category has the same share in the training and test sets, and the results are reproducible.

  2. 02

    Leave the AQI value itself out of the features

    The category is derived from the AQI, so including it would give every model 100% and make the comparison meaningless.

  3. 03

    Evaluate five models on the same held-out test set

    kNN, SVM, decision tree, random forest and a neural network compared on AUC, accuracy, F1, MCC and confusion matrices.

  4. 04

    Also run k-means to see how the data clusters naturally

    k from 2 to 8, choosing the number of clusters by silhouette score, compared against the official six categories.

Trade-offs

  • The test set has only 17 rows from a single snapshot in time, so 100% accuracy doesn't mean it would be as accurate at another time
  • The decision tree has an edge because AQI categories are themselves thresholds on pollutant values; with noisier data that wouldn't necessarily hold

Results

  • The decision tree and random forest got all 17 test rows right; kNN, SVM and the neural network each missed one, always to an adjacent category
  • k-means scored best at k=3 (silhouette 0.581): the official scale has six categories, but the data naturally separates into only three groups — good / moderate / unhealthy and worse

Method

  • Stratified split: 80% training (68 rows) / 20% test (17 rows), with a fixed random seed for reproducibility
  • The AQI value is set as a meta attribute, not a feature: the category is derived from the AQI, so including it would give every model 100% and make the comparison meaningless
  • Five models evaluated on the held-out test set by AUC, accuracy, F1, MCC and confusion matrices

Results

  • Decision tree and random forest: accuracy 1.000, all 17 correct
  • kNN, SVM and neural network: accuracy 0.941, one miss each — all classified "unhealthy" as the adjacent "unhealthy for sensitive groups"
  • Why the decision tree wins: AQI categories are thresholds on pollutant values, which matches how a decision tree splits; with noisier data that wouldn't necessarily hold (no free lunch)
  • k-means from k=2 to 8 scored best at k=3 (silhouette 0.581): six official categories, but the data naturally separates into only three groups — good / moderate / unhealthy and worse

Final report for the Big Data Analytics Practice course. The test set has only 17 rows, so 100% accuracy doesn't mean the model would be as accurate at another time.

Type to search projects and posts too