Spaces:
Running
Running
| """Dosing inference.""" | |
| from __future__ import annotations | |
| from app.models.dosing.pkpd_state import PKPDState | |
| def infer_dosing_quality(state: PKPDState) -> dict[str, float]: | |
| target_attainment = max(0.0, min(1.0, 1.0 - abs(state.effect_level - 0.62))) | |
| toxicity_proxy = min(1.0, state.toxicity_level + state.organ_stress * 0.2 + state.interaction_load * 0.12) | |
| underdose_proxy = min(1.0, state.underdose_risk + max(0.0, 0.3 - state.effect_level)) | |
| return { | |
| "target_attainment": target_attainment, | |
| "toxicity_proxy": toxicity_proxy, | |
| "underdose_proxy": underdose_proxy, | |
| "measurement_need": max(toxicity_proxy, underdose_proxy), | |
| } | |