-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
38 lines (25 loc) · 884 Bytes
/
Copy pathbase.py
File metadata and controls
38 lines (25 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Base interfaces for clinically-constrained validation rules."""
from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any
import pandas as pd
@dataclass(frozen=True)
class CandidateCorrection:
"""A proposed cell-level correction generated by a constraint."""
row_index: int
column: str
proposed_value: Any
confidence: float
rationale: str
constraint_name: str
@dataclass(frozen=True)
class ConstraintResult:
"""Outcome of applying one clinical constraint."""
candidates: list[CandidateCorrection]
class ClinicalConstraint(ABC):
"""Abstract clinical constraint interface."""
name: str = "base_constraint"
@abstractmethod
def apply(self, df: pd.DataFrame) -> ConstraintResult:
"""Generate correction candidates for the provided dataset."""