# 060. Humidity and sensor calibration error

**Question:** Does the fixed CO calibration model perform differently across relative-humidity bands?

## Result

The largest computed metric is 0.4022 for (50.0, 70.0]; the smallest is 0.2287 for (0.0, 30.0]. Metric: mae (CO reference-unit MAE).

Missing humidity is retained in an explicit nan group. Error differences do not identify a humidity effect independently of pollutant levels.

![Humidity and sensor calibration error](outputs/chart.png)

| humidity_band | test_hours | mae |
| --- | --- | --- |
| (0.0, 30.0] | 183 | 0.2287 |
| (30.0, 50.0] | 597 | 0.3216 |
| (50.0, 70.0] | 484 | 0.4022 |
| (70.0, 100.0] | 195 | 0.2651 |

The chart shows 4 of 4 result rows; the table previews the first 4 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

Stratify held-out residuals by declared humidity ranges.

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.

## Evaluation

First 80% of ordered observations train; final 20% test. Training observations: 6,139; test observations: 1,535. Fixed configurations specified before scoring; no tuning on the holdout.

Target: `co_gt`. Features: pt08_s1_co, pt08_s2_nmhc, pt08_s3_nox, pt08_s4_no2, pt08_s5_o3, t, rh, ah. Model results and row membership are recorded in [evaluation.json](outputs/evaluation.json).

## Decision and limitations

Use diagnostic differences to plan a calibration study across environmental conditions.

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/060-humidity-and-sensor-calibration-error/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.
