Download scorer.py from ClarusC64/clinical-systemic-drift-fingerprint-extraction-v0.1: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/datasets/ClarusC64/clinical-systemic-drift-fingerprint-extraction-v0.1/resolve/main/scorer.py
- Command line
-
hf download hf://datasets/ClarusC64/clinical-systemic-drift-fingerprint-extraction-v0.1/scorer.py
-
curl -L -o scorer.py https://huggingface.co/datasets/ClarusC64/clinical-systemic-drift-fingerprint-extraction-v0.1/resolve/main/scorer.py
1.05 kB
| from dataclasses import dataclass | |
| from typing import Dict, Any, List | |
| class ScoreResult: | |
| score: float | |
| details: Dict[str, Any] | |
| def score(sample: Dict[str, Any], prediction: str) -> ScoreResult: | |
| p = (prediction or "").lower() | |
| words_ok = len(p.split()) <= 520 | |
| has_vector = "drift" in p or "fingerprint" in p | |
| has_axes = "axis" in p or "system" in p | |
| has_time = "temporal" in p or "onset" in p or "offset" in p | |
| has_reversible = "reversible" in p or "rebound" in p | |
| has_coherence = "coherence" in p or "net" in p | |
| raw = ( | |
| 0.15 * int(words_ok) + | |
| 0.25 * int(has_vector) + | |
| 0.20 * int(has_axes) + | |
| 0.20 * int(has_time) + | |
| 0.10 * int(has_reversible) + | |
| 0.10 * int(has_coherence) | |
| ) | |
| return ScoreResult(score=min(1.0, raw), details={"id": sample.get("id")}) | |
| def aggregate(results: List[ScoreResult]) -> Dict[str, Any]: | |
| if not results: | |
| return {"mean": 0.0, "n": 0} | |
| return {"mean": sum(r.score for r in results) / len(results), "n": len(results)} | |