c3749daf48
Tests / test-linux (3.13) (push) Failing after 0s
Tests / test-linux (3.11) (push) Failing after 1s
Tests / lint (push) Failing after 0s
Tests / test-linux (3.9) (push) Failing after 1s
Docker / build (push) Failing after 1s
Docker / build-gpu (push) Failing after 2s
Tests / test-windows (push) Has been cancelled
Tests / test-macos (push) Has been cancelled
17 lines
683 B
Python
17 lines
683 B
Python
"""Calibration scoring: exact-match against single-class label."""
|
|
from __future__ import annotations
|
|
|
|
|
|
def score(predicted: str, label: str, classes: list[str]) -> dict:
|
|
"""Return {"correct": bool, "predicted_normalized": str}."""
|
|
p = predicted.strip().lower().strip(".,;:'\"")
|
|
target = label.strip().lower()
|
|
correct = p == target
|
|
if not correct:
|
|
for c in classes:
|
|
if p == c.strip().lower():
|
|
# Predicted a valid class, just not the target.
|
|
return {"correct": False, "predicted_normalized": p}
|
|
return {"correct": False, "predicted_normalized": p}
|
|
return {"correct": True, "predicted_normalized": p}
|