Spaces:
Running
Running
File size: 679 Bytes
877add7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | """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),
}
|