ClarusC64/clinical-fragility-amplification-detection-v0.1
from dataclasses import dataclass from typing import Dict, Any, List @dataclass 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_index = "fragility" in p and "index" in p has_triggers = "trigger" in p or "missed" in p or "dose" in p has_rebound = "rebound" in p or "withdraw" in p has_range = "operating" in p or "narrow" in p… See the full description on the dataset page: https://huggingface.co/datasets/ClarusC64/clinical-fragility-amplification-detection-v0.1.
from dataclasses import dataclass from typing import Dict, Any, List
@dataclass 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
hasindex = "fragility" in p and "index" in p hastriggers = "trigger" in p or "missed" in p or "dose" in p hasrebound = "rebound" in p or "withdraw" in p hasrange = "operating" in p or "narrow" in p has_mitigation = "mitigation" in p or "taper" in p or "monitor" in p
raw = ( 0.15 int(words_ok) + 0.25 int(hasindex) + 0.25 * int(hastriggers) + 0.15 int(has_rebound) + 0.10 int(hasrange) + 0.10 * int(hasmitigation) ) 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)}
