sessions of 2026-11-18 (the optimization campaign; three runs without summary, interrupted and rerun)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a81c53cd9
commit
0cfbd1b7bc
363 files changed
+30822
No files matched your search
@@ -0,0 +1,10 @@
|
||||
# Lists the labels of a JSONL file touching [FROM, TO): id, start, end, family, description (truncated to N chars).
|
||||
import json, sys
|
||||
path, a, b = sys.argv[1], sys.argv[2], sys.argv[3]
|
||||
n = int(sys.argv[4]) if len(sys.argv) > 4 else 300
|
||||
for line in open(path, encoding="utf-8"):
|
||||
if not line.strip():
|
||||
continue
|
||||
e = json.loads(line)
|
||||
if e["start"] < b and e["end"] >= a:
|
||||
print(e["id"], e["start"], e["end"], e["family"], "|", e.get("description", "")[:n])
|
||||
@@ -0,0 +1,30 @@
|
||||
# Per label of a range: share of its instants flagged in its family, and which families the detectors put there; then per
|
||||
# event: share of its instants inside a label of its family. Args: <detectors dir> <station folder> <labels.jsonl> FROM TO
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(sys.argv[1]).resolve() / "bench"))
|
||||
import score # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
det, folder, lab, a, b = sys.argv[1:6]
|
||||
start, end = iso(parse_time(a)), iso(parse_time(b))
|
||||
ms = load(folder)
|
||||
labels = score.read_labels(lab, start, end)
|
||||
evts = score.events(ms, start, end, folder)
|
||||
inst = sorted({iso(m["t"]) for v in ms.values() for m in v if start <= iso(m["t"]) < end})
|
||||
fl = {t: {v["category"] for v in evts if v["start"] <= t <= v["end"]} for t in inst}
|
||||
print("== labels")
|
||||
for e in labels:
|
||||
ts = [t for t in inst if e["start"] < t < e["end"]]
|
||||
hit = sum(e["family"] in fl[t] for t in ts)
|
||||
other = {}
|
||||
for t in ts:
|
||||
for c in fl[t] - {e["family"]}:
|
||||
other[c] = other.get(c, 0) + 1
|
||||
print(f"{e['id']:<15} {e['start'][5:16]} {e['end'][5:16]} {e['family']:<20} {hit}/{len(ts)} other: {other}")
|
||||
print("== events")
|
||||
for v in evts:
|
||||
ts = [t for t in inst if v["start"] <= t <= v["end"]]
|
||||
ok = sum(any(e["family"] == v["category"] and e["start"] < t < e["end"] for e in labels) for t in ts)
|
||||
if ok < len(ts):
|
||||
ids = sorted({e["id"] + ":" + e["family"][:4] for e in labels for t in ts if e["start"] < t < e["end"]})
|
||||
print(f"{v['start'][5:16]} {v['end'][5:16]} {v['category']:<20} {v['episodes'][0]['label']:<28} wrong {len(ts)-ok}/{len(ts)} labels: {' '.join(ids)[:150]}")
|
||||
@@ -0,0 +1,30 @@
|
||||
# Per hour of [FROM, TO) (window read with 3 days of history): heat_shimmer's share of agitated sensors (>= RATIO) and
|
||||
# median error_value ratio, as visibility.heat_shimmer computes them; label families. Args: <detectors dir> <station> <labels> FROM TO
|
||||
import statistics, sys
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(sys.argv[1]).resolve() / "bench"))
|
||||
import score # noqa: E402
|
||||
import visibility as V # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
det, folder, lab, a, b = sys.argv[1:6]
|
||||
start, end = parse_time(a), parse_time(b)
|
||||
ms = {s: k for s, v in load(folder).items() if (k := [m for m in v if start - timedelta(days=3) <= m["t"] < end])}
|
||||
labels = score.read_labels(lab, iso(start), iso(end))
|
||||
hours = {}
|
||||
for s, v in ms.items():
|
||||
ag = V._ratios([(y["t"], abs(y["corr_x"] - x["corr_x"]) + abs(y["corr_y"] - x["corr_y"]))
|
||||
for x, y in zip(v, v[1:]) if x["corr_x"] is not None and y["corr_x"] is not None])
|
||||
er = V._ratios([(m["t"], m["error_value"]) for m in v if m["error_value"] is not None])
|
||||
for h in ag.keys() & er.keys():
|
||||
hours.setdefault(h, {})[s] = (ag[h], er[h])
|
||||
for h, r in sorted(hours.items()):
|
||||
if not (start <= h < end):
|
||||
continue
|
||||
share = sum(x >= V.RATIO for x, _ in r.values()) / len(r)
|
||||
e = statistics.median(y for _, y in r.values())
|
||||
agm = statistics.median(x for x, _ in r.values())
|
||||
ti = iso(h)
|
||||
fam = ",".join(sorted({l["family"][:4] + l["id"][11:] for l in labels if l["start"] < ti < l["end"]}))
|
||||
flag = "T" if share >= V.SHARE and e >= V.RATIO else " "
|
||||
print(ti[5:16], f"share={share:4.2f} agit={agm:5.2f} err={e:5.2f} {flag}", fam)
|
||||
@@ -0,0 +1,38 @@
|
||||
# Per instant of [FROM, TO) (window read with 3 days of history, as score.py): median error_value z over the sensors (as
|
||||
# visibility.py), share of sensors with z>=2.5, number high (K_MAD), number strong (rejected), label families.
|
||||
# Args: <detectors dir> <station folder> <labels.jsonl> FROM TO [hourly]
|
||||
import statistics, sys
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(sys.argv[1]).resolve() / "bench"))
|
||||
import score # noqa: E402
|
||||
import visibility as V # noqa: E402
|
||||
from episodes import level # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
det, folder, lab, a, b = sys.argv[1:6]
|
||||
hourly = len(sys.argv) > 6
|
||||
start, end = parse_time(a), parse_time(b)
|
||||
ms = {s: k for s, v in load(folder).items() if (k := [m for m in v if start - timedelta(days=3) <= m["t"] < end])}
|
||||
labels = score.read_labels(lab, iso(start), iso(end))
|
||||
z, high, strong = {}, {}, {}
|
||||
for s, v in ms.items():
|
||||
e = [m["error_value"] for m in v if m["error_value"] is not None]
|
||||
if len(e) < 10:
|
||||
continue
|
||||
med, mad = level(e)
|
||||
for m in v:
|
||||
t, x = m["t"], m["error_value"]
|
||||
if x is None:
|
||||
continue
|
||||
z.setdefault(t, {})[s] = (x - med) / mad
|
||||
if x > med + V.K_MAD * mad and x > V.FACTOR * med:
|
||||
high.setdefault(t, set()).add(s)
|
||||
if m["error_threshold"] and x > m["error_threshold"] and x > V.FACTOR * med:
|
||||
strong.setdefault(t, set()).add(s)
|
||||
for t in sorted(z):
|
||||
if not (start <= t < end) or (hourly and t.minute >= 5):
|
||||
continue
|
||||
ti = iso(t)
|
||||
fam = ",".join(sorted({e["family"][:4] + e["id"][11:] for e in labels if e["start"] < ti < e["end"]}))
|
||||
zs = list(z[t].values())
|
||||
print(ti[5:16], f"medz={statistics.median(zs):6.2f} q25={statistics.quantiles(zs, n=4)[0]:6.2f} n={len(zs):2d} high={len(high.get(t, ())):2d} strong={len(strong.get(t, ())):2d}", fam)
|
||||
Reference in new issue
Block a user