# 052. High-load interval warning benchmark

**Question:** Can past appliance use rank unusually high-load intervals one hour ahead?

## Result

The largest computed metric is 0.2948 for Random forest; the smallest is 0.07502 for Prior baseline. Metric: average_precision (Average precision).

High load is strictly greater than the training 90th percentile (210 Wh). It is a study threshold, not a safety limit.

![High-load interval warning benchmark](outputs/chart.png)

| model | accuracy | balanced_accuracy | macro_f1 | roc_auc | average_precision | brier |
| --- | --- | --- | --- | --- | --- | --- |
| Prior baseline | 0.925 | 0.5 | 0.4805 | 0.5 | 0.07502 | 0.06991 |
| Logistic regression | 0.9268 | 0.5291 | 0.5366 | 0.8135 | 0.2935 | 0.06171 |
| Random forest | 0.9217 | 0.5513 | 0.5701 | 0.8565 | 0.2948 | 0.06077 |

The chart shows 3 of 3 result rows; the table previews the first 3 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

Threshold defined from the training prefix only, with chronological classification.

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: 15,672; test observations: 3,919. Fixed models; default decision threshold; no holdout tuning.

Target: `high_load`. Features: hour, weekday, lag_6, lag_12, lag_144. Model results and row membership are recorded in [evaluation.json](outputs/evaluation.json).

## Decision and limitations

Choose warning costs and evaluate on a fresh period before defining an operational alert.

Measurements come from one home over a limited period. Energy is Wh per recorded 10-minute interval. This is not a representative household sample; tariffs and occupancy labels are unavailable. 

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/052-high-load-interval-warning-benchmark/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

[Appliances Energy Prediction](https://archive.ics.uci.edu/dataset/374/appliances+energy+prediction), Candanedo (2017). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/energy.json) and [prepared-data audit](../../data/provenance/energy_prepared.json) record the downloaded files, field coverage and hashes.
