Spaces:
Running
Running
| """Uncertainty estimates.""" | |
| from __future__ import annotations | |
| from app.common.types import PolyGuardState | |
| def estimate_uncertainty(state: PolyGuardState) -> float: | |
| missing = 0 | |
| total = 3 | |
| if state.patient.labs.egfr is None: | |
| missing += 1 | |
| if state.patient.labs.ast is None: | |
| missing += 1 | |
| if state.patient.labs.alt is None: | |
| missing += 1 | |
| base = missing / total | |
| conflict_penalty = min(0.3, 0.1 * len(state.unresolved_conflicts)) | |
| return max(0.0, min(1.0, base + conflict_penalty)) | |