U.S. EPA air data · 2025 county observations
Air quality
regimes.
Two counties can have the same number of high-AQI days and very different pollutant patterns. Explore how four clustering methods group the same EPA observations.
- EPA rows screened
- 985
- Counties in the study
- 789
- Held-out counties
- 157
- Clustering methods
- 4
Explore county assignments
Switch methods, choose a pair of features and inspect a county. Plot positions stay fixed when the method changes.
Reassigns every training county to its nearest center, then updates each center to the mean of its assigned rows.
County observations
789 of 789 counties
Each mark is a county. Overlapping marks share coordinates. Assignments use all five features.
Held-out county · FIPS 04019
PimaArizona
- Reporting days
- 365
- Median AQI
- 54
- 90th-percentile AQI
- 80
- Days above AQI 100
- 2.2%
- Ozone-defining days
- 51%
- PM₂.₅-defining days
- 30.7%
Aligned assignments
County assignments across the US
Each mark represents an EPA county or county equivalent. The map follows the explorer’s method and filters.
789 mapped
- Regime 1
- Regime 2
- Regime 3
- Regime 4
What defines each regime?
Means of county observations, including both fitting and held-out counties. Bars share a scale within each feature.
Regime 1
145 counties- Median AQI
- 27.2
- 90th pct. AQI
- 51.3
- Days >100
- 0.5%
- Ozone days
- 1.3%
- PM₂.₅ days
- 86.7%
Regime 2
218 counties- Median AQI
- 38.7
- 90th pct. AQI
- 55.8
- Days >100
- 0.5%
- Ozone days
- 87.5%
- PM₂.₅ days
- 10.5%
Regime 3
413 counties- Median AQI
- 43.5
- 90th pct. AQI
- 63.4
- Days >100
- 1%
- Ozone days
- 39.7%
- PM₂.₅ days
- 58.7%
Regime 4
13 counties- Median AQI
- 68.5
- 90th pct. AQI
- 116.8
- Days >100
- 16%
- Ozone days
- 47.5%
- PM₂.₅ days
- 35.5%
Regime numbers follow increasing mean training p90 AQI for k-means. For each other method, display colors match the k-means groups through the one-to-one mapping that maximizes overlap on training counties. This mapping makes membership changes visible across methods.
Where the methods agree
Every selected model predicts the same held-out counties. Compare their nearest-center distances and whether they group the same counties together.
Held-out distortion
Mean squared Euclidean distance to the nearest center. Each county’s five squared feature differences are summed before averaging across counties.
- k-means
- 1.255
- e-means
- 1.141
- o-means
- 1.119
- p-means
- 1.329
Held-out assignment agreement
Adjusted Rand index (ARI). Identical groupings score 1. A score near 0 indicates chance-level agreement. Group numbers can differ.
| Method | k | e | o | p |
|---|---|---|---|---|
| k-means | 1.000 | 1.000 | 1.000 | 0.545 |
| e-means | 1.000 | 1.000 | 1.000 | 0.545 |
| o-means | 1.000 | 1.000 | 1.000 | 0.545 |
| p-means | 0.545 | 0.545 | 0.545 | 1.000 |
Three methods recovered the same held-out grouping
K-means, e-means and o-means reached ARI 1.000 on all 157 held-out counties. O-means had the lowest held-out distortion in these runs, even though the three methods grouped those counties identically. Their returned centers were different.
P-means shifted a boundary
P-means reached ARI 0.545 against the other three methods. After aligning colors, held-out counties such as Pima, Arizona, and Philadelphia, Pennsylvania, moved from the mixed-pollutant group to a broader group under this p-means fit.
Inspect the selected fits
| Method | Seed | Train distortion | Fit diagnostics |
|---|---|---|---|
| k-means | 43 | 1.800 | 17 iterations · converged |
| e-means | 44 | 1.808 | batch 128 · closing last_pass |
| o-means | 44 | 1.813 | batch 128 · 3 cells / 2 probes · closing last_pass |
| p-means | 43 | 2.453 | batch 128 · 3 cells / 2 probes · closing recency_weighted · length 0.5 |
From EPA records to four fitted models
The study uses one county-level record per place. Each method receives the same five-feature training matrix and the same evaluation split.
Screen observations
Keep counties and county equivalents in the 50 states and D.C. with at least 300 AQI reporting days. Preserve state and county FIPS.
Build five features
Use the EPA median and 90th percentile. Divide three counts by each county’s own reporting days.
Fit four methods
Standardize using training rows only. Fit four centers per method and select one run using training distortion.
Check held-out counties
Assign each held-out county to its nearest returned center. Compare distortion and agreement on the held-out assignments.
The shared feature recipe
- Median AQI
- 90th-percentile AQI
- Days above AQI 100 as a share of reporting days
- Ozone-defining days as a share of reporting days
- PM₂.₅-defining days as a share of reporting days
The pollutant shares count the days when each pollutant defined the reported AQI. A county can have days defined by other pollutants. Correlated features give related aspects of severity and pollutant mix more influence in the distance.
The fitting protocol
The program sorts counties by FIPS, shuffles with seed 2026 and holds out one fifth rounded down. The split contains 632 training and 157 held-out counties. Each feature is centered and divided by its population standard deviation, both measured on the training counties.
The CPU Float64 run used one worker. K-means allowed 100 Lloyd iterations with tolerance 0.000001. E-, o- and p-means used three passes, batch size 128 and initial step parameter 0.5. O- and p-means used three coarse cells and two probes. P-means used a closing length of 0.5.
Reproduce the study in Aner
The companion contains the executable Aner program, its research notebook, the input identity and the captured fit and evaluation outputs.
Recorded runtime · Aner 0.1.0
One input matrix, four native APIs
All four fits call aner.ml. The excerpt shows the fit controls for a single restart on the standardized training tensor.
import aner.ml
// x_train is the standardized training tensor.
let k = ml.fit_kmeans(features: x_train, clusters: 4,
max_iterations: 100, tolerance: 0.000001, seed: 42)
let e = ml.fit_emeans(features: x_train, clusters: 4,
epochs: 3.0, seed: 42, batch_size: 128, alpha0: 0.5)
let o = ml.fit_omeans(features: x_train, clusters: 4,
epochs: 3.0, seed: 42, batch_size: 128, alpha0: 0.5,
coarse_cells: 3, probes: 2)
let p = ml.fit_pmeans(features: x_train, clusters: 4,
epochs: 3.0, seed: 42, batch_size: 128, alpha0: 0.5,
coarse_cells: 3, probes: 2, closing_length: 0.5)Inspect evidence identities
- EPA archive SHA-256
72b022b3828c611007df5ededcb5933b0bce877077573dbd66a0c1c66d467130- Aner output SHA-256
b66e6bb671d9ee0f49d590736f927bdebc9e3b143552a88e8928c3684b153961- Companion commit
5df217516e9a48ebf2e86e668441c5c2d15e1e6e