Download scorer.py from ClarusC64/coldchain-power-continuity-coherence-risk-v0.1: direct link, hf CLI and curl.
- Browser
- Download file 762 Bytes
-
https://huggingface.co/datasets/ClarusC64/coldchain-power-continuity-coherence-risk-v0.1/resolve/main/scorer.py
- Command line
-
hf download hf://datasets/ClarusC64/coldchain-power-continuity-coherence-risk-v0.1/scorer.py
-
curl -L -o scorer.py https://huggingface.co/datasets/ClarusC64/coldchain-power-continuity-coherence-risk-v0.1/resolve/main/scorer.py
762 Bytes
| VALID = {"coherent","incoherent"} | |
| def score(predictions, references): | |
| ref = {r["uid"]: r for r in references} | |
| total = 0 | |
| correct = 0 | |
| invalid = 0 | |
| for p in predictions: | |
| uid = p.get("uid") | |
| if uid not in ref: | |
| continue | |
| gt = ref[uid].get("ground_truth_label") | |
| if not gt: | |
| continue | |
| total += 1 | |
| pred = str(p.get("model_response","")).strip().lower() | |
| if pred not in VALID: | |
| invalid += 1 | |
| continue | |
| if pred == gt: | |
| correct += 1 | |
| return { | |
| "accuracy": correct/total if total else 0.0, | |
| "n_scored": total, | |
| "invalid_rate": invalid/total if total else 0.0, | |
| "labels": ["coherent","incoherent"] | |
| } | |