# 058. Sensor association drift

**Question:** How stable is the relationship between a CO-sensitive sensor and the reference over calendar months?

## Result

The largest computed metric is 0.9526 for 2004-04; the smallest is 0.8122 for 2005-04. Metric: rho (Spearman correlation).

A changing correlation can reflect pollution range or environmental shifts, not necessarily hardware deterioration.

![Sensor association drift](outputs/chart.png)

| month | paired_hours | rho | median_co | median_sensor |
| --- | --- | --- | --- | --- |
| 2004-03 | 492 | 0.9284 | 2.1 | 1,207 |
| 2004-04 | 468 | 0.9526 | 2 | 1,143 |
| 2004-05 | 592 | 0.9045 | 1.8 | 1,065 |
| 2004-06 | 607 | 0.9123 | 1.8 | 1,031 |
| 2004-07 | 558 | 0.8812 | 1.6 | 1,033 |
| 2004-08 | 428 | 0.8575 | 1.2 | 972 |
| 2004-09 | 555 | 0.9445 | 1.8 | 1,040 |
| 2004-10 | 392 | 0.951 | 2.5 | 1,219 |
| 2004-11 | 679 | 0.9087 | 2.3 | 1,111 |
| 2004-12 | 561 | 0.8789 | 2.3 | 1,081 |
| 2005-01 | 616 | 0.8439 | 1.7 | 1,103 |
| 2005-02 | 588 | 0.863 | 1.65 | 1,043 |
| 2005-03 | 723 | 0.8247 | 1.7 | 1,135 |
| 2005-04 | 85 | 0.8122 | 1 | 928 |

The chart shows 14 of 14 result rows; the table previews the first 14 in the analysis-defined order. [Download the full result table](outputs/results.csv). Numerical values are computed from the source; missing results stay unavailable.

## Method

Monthly paired correlation, coverage and median level comparison.

The study uses shared source preparation and reusable statistical routines. Its specific transformations are in [analysis.py](analysis.py), and common model/evaluation code is in [portfolio/methods.py](../../portfolio/methods.py). The [notebook](analysis.ipynb) executes the study and displays the saved results.

## Decision and limitations

Investigate changes in calibration conditions before updating a monitoring model.

The -200 sentinel is treated as missing. Reference instruments have incomplete coverage; comparisons use paired observations. Sensor calibration is retrospective, not a health or regulatory compliance assessment. 

Related studies may share observations or holdouts. These are focused analytical studies, not independent replications or deployed business systems. Any model refinements informed by these results need new untouched evaluation data. No commercial impact is inferred from an association or backtest.

## Reproduce

From the repository root, after installing `requirements.txt`:

```powershell
python projects/058-sensor-association-drift/analysis.py
```

Source data are downloaded automatically if absent. Original archives are retained unchanged and checked by SHA-256. The cleaned cache normalizes column names; field-specific changes are visible in [data preparation](../../portfolio/data.py). Runtime evidence is in [receipt.json](outputs/receipt.json).

## Source

[Air Quality](https://archive.ics.uci.edu/dataset/360/air+quality), De Vito (2008). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/air.json) and [prepared-data audit](../../data/provenance/air_prepared.json) record the downloaded files, field coverage and hashes.
