Label keys start/end/family in the bench and the docs (benchmark unchanged); knowledge path in data.py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-16 12:40:03 +01:00
1 parent b01a9116d0
commit 0abba2d0ed
5 files changed
+10 -10

No files matched your search

+2 -2
View File
@@ -20,10 +20,10 @@ from data import iso, parse_time # on the path through score
def label_range(path):
"""Labels JSONL -> (start, end) iso, in whole UTC days, end excluded."""
labels = score.read_labels(path)
start = min(e["debut"] for e in labels)[:10]
start = min(e["start"] for e in labels)[:10]
# ponytail: the end of the labelled batch is not written; midnight closest to the last bound (a label bound
# overflows by one measurement after midnight)
end = iso(parse_time(max(e["fin"] for e in labels)) + timedelta(hours=12))[:10]
end = iso(parse_time(max(e["end"] for e in labels)) + timedelta(hours=12))[:10]
return iso(parse_time(start)), iso(parse_time(end))
+5 -5
View File
@@ -6,7 +6,7 @@ event is its family.
found: labelled instants that the detectors also flagged (share of the labelled ones);
correct: flagged instants that a label also puts in the family (share of the flagged ones).
The score is a fact, not a verdict: the labels can be wrong too. No label on the range: exits with an error.
Labels: a JSONL file, one label per line, {"id", "debut", "fin", "categorie", "description"} (UTC ISO times, categorie =
Labels: a JSONL file, one label per line, {"id", "start", "end", "family", "description"} (UTC ISO times);
the family); its bounds are the healthy measurement before and after the anomaly.
Usage: python3 score.py <station folder> --labels <labels.jsonl> --from YYYY-MM-DD --to YYYY-MM-DD
"""
@@ -48,7 +48,7 @@ def read_labels(path, start=None, end=None):
return []
with open(path, encoding="utf-8") as f:
return [e for e in map(json.loads, filter(str.strip, f))
if (end is None or e["debut"] < end) and (start is None or e["fin"] >= start)]
if (end is None or e["start"] < end) and (start is None or e["end"] >= start)]
def family_scores(folder, labels_path, start, end):
@@ -60,11 +60,11 @@ def family_scores(folder, labels_path, start, end):
evts = events(measurements, start, end, folder)
instants = sorted({iso(m["t"]) for ms in measurements.values() for m in ms if start <= iso(m["t"]) < end})
# bounds excluded: they are the healthy measurement before and after; a hole, without a measurement inside, keeps them
empty = {i for i, e in enumerate(labels) if not any(e["debut"] < t < e["fin"] for t in instants)}
empty = {i for i, e in enumerate(labels) if not any(e["start"] < t < e["end"] for t in instants)}
pairs = []
for t in instants:
a = {e.get("categorie", "no family") for i, e in enumerate(labels)
if e["debut"] < t < e["fin"] or (i in empty and e["debut"] <= t <= e["fin"])} - {"None"}
a = {e.get("family", "no family") for i, e in enumerate(labels)
if e["start"] < t < e["end"] or (i in empty and e["start"] <= t <= e["end"])} - {"None"}
d = {v["category"] for v in evts if v["start"] <= t <= v["end"]}
pairs.append((a, d))
return count(pairs), labels