Spaces:
Running
Running
| """Tabular risk heads.""" | |
| from __future__ import annotations | |
| def predict_risk_heads(features: dict[str, float]) -> dict[str, float]: | |
| med_count = features.get("med_count", 0.0) | |
| frailty = features.get("frailty", 0.5) | |
| adherence = features.get("adherence", 0.7) | |
| monitoring = features.get("monitoring_gap_count", 0.0) | |
| ade_history = features.get("ade_history_count", 0.0) | |
| egfr = features.get("egfr", 60.0) | |
| ast = features.get("ast", 30.0) | |
| alt = features.get("alt", 30.0) | |
| ade = min(1.0, 0.18 + med_count / 19.0 + frailty * 0.27 + monitoring * 0.04) | |
| hosp = min(1.0, 0.1 + ade * 0.58 + (1.0 - adherence) * 0.2 + ade_history * 0.05) | |
| falls = min(1.0, 0.1 + frailty * 0.48 + med_count / 33.0 + ade_history * 0.06) | |
| organ_risk = max(0.0, (35.0 - egfr) / 35.0) + max(0.0, (ast - 80.0) / 80.0) + max(0.0, (alt - 80.0) / 80.0) | |
| destabilization = min(1.0, 0.16 + (1.0 - adherence) * 0.52 + organ_risk * 0.22) | |
| burden = min(1.0, med_count / 12.0) | |
| return { | |
| "ade_proxy": ade, | |
| "hospitalization_proxy": hosp, | |
| "falls_proxy": falls, | |
| "destabilization_proxy": destabilization, | |
| "burden_proxy": burden, | |
| } | |