baseline_learn
Learn a conservative normal band for a tag from historical samples, using robust percentiles. Returns a baseline or an explicit insufficient-data verdict when data is scarce.
Instructions
[READ][risk=low] Learn a conservative per-tag normal band from local history.
Source is ~/.iaiops/data.db — the local store written by
historian_push(sink="sqlite") — NOT a live device read. Learns robust
percentiles (p1/p99 + median/MAD, no ML) from the tag's own samples,
segmented at the latest change recorded via baseline_record_change (the band
reflects only the post-change regime). REFUSES with an explicit
insufficient_data verdict (listing exactly what is missing) below 100 usable
samples or under 24h of span — it never invents a band from thin data. On
success the band is persisted to ~/.iaiops/baselines.json (owner-only local
metadata, not an OT write).
Args:
tag: Tag name to learn, e.g. 'line1.temp'.
endpoint: Only samples from this endpoint label.
since: Only samples at/after this ISO-8601 time.
Returns dict: {status: 'ok'|'insufficient_data', tag, band:{p1,p99,median,mad},
n_samples, window:{from_ts,to_ts,span_s}, segment, missing?:[...], note}.
Example: baseline_learn(tag="line1.temp", since="2026-06-01T00:00:00").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | Yes | ||
| since | No | ||
| endpoint | No |