Step 2: the evaluator (the measure of bench/score.py on predictions per instant; the rules reproduce it exactly)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b2d3734152
commit
c04cbc90bb
4 files changed
+153
-1
No files matched your search
@@ -0,0 +1,18 @@
|
||||
"""Checks of evaluate.py: python test_evaluate.py (the check against the benchmark itself is `evaluate.py rules`)."""
|
||||
import numpy as np
|
||||
|
||||
import evaluate
|
||||
|
||||
instants = ["2026-10-01T00:00Z", "2026-10-01T00:15Z", "2026-10-01T00:30Z"]
|
||||
yhat = evaluate.events_to_yhat([{"start": "2026-10-01T00:15Z", "end": "2026-10-01T00:30Z", "category": "Obstruction"},
|
||||
{"start": "2026-10-01T00:00Z", "end": "2026-10-01T00:00Z", "kind": "Visibility"}],
|
||||
instants)
|
||||
assert yhat[:, 1].tolist() == [0, 1, 1] and yhat[:, 0].tolist() == [1, 0, 0] # bounds included
|
||||
y = np.zeros_like(yhat)
|
||||
y[1:, 1] = 1
|
||||
y[2, 0] = 1
|
||||
c = evaluate.counts(y, yhat)
|
||||
assert c == {"Visibility": [1, 1, 0], "Obstruction": [2, 2, 2]}, c
|
||||
assert evaluate.regressions({"Obstruction": [10, 10, 5]}, {"Obstruction": [10, 4, 4]}) == [("Obstruction", "found", 50, 40)]
|
||||
assert evaluate.regressions({"Obstruction": [10, 10, 5]}, {"Obstruction": [10, 10, 5]}) == []
|
||||
print("ok")
|
||||
Reference in new issue
Block a user