-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added interface for comparer and builder
- Loading branch information
1 parent
0083cd8
commit b3b4afc
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from __future__ import annotations | ||
from typing import List, Optional, Union | ||
|
||
from medmodels.medrecord.types import Group, GroupInputList, MedRecordAttribute | ||
|
||
from medmodels.statistic_evaluations.comparer.data_comparer import DataComparer | ||
from medmodels.medrecord.querying import NodeOperation | ||
|
||
class ComparerBuilder: | ||
Check failure on line 9 in medmodels/statistic_evaluations/comparer/builder.pyi GitHub Actions / lintRuff (I001)
|
||
patients_group: Optional[Group] | ||
time_attribute: Optional[MedRecordAttribute] | ||
concept_group: Optional[Union[GroupInputList, Group]] | ||
subpopulations_groups: Optional[GroupInputList] | ||
subpopulations_queries: Optional[List[NodeOperation]] | ||
control_population: Optional[Union[Group, NodeOperation]] | ||
top_k_concepts: Optional[int] | ||
alpha: Optional[float] | ||
|
||
def with_patients_group(self, group: Group) -> ComparerBuilder: ... | ||
def with_time_attributes( | ||
self, attribute: MedRecordAttribute | ||
) -> ComparerBuilder: ... | ||
def with_concept_group( | ||
self, group: Union[Group, GroupInputList] | ||
) -> ComparerBuilder: ... | ||
def with_subpopulations( | ||
self, | ||
groups: GroupInputList, | ||
queries: List[NodeOperation], | ||
control_population: Union[Group, NodeOperation], | ||
) -> ComparerBuilder: ... | ||
def with_top_k(self, k: int) -> ComparerBuilder: ... | ||
def with_significance_level(self, alpha: float) -> ComparerBuilder: ... | ||
def build(self) -> DataComparer: ... |
68 changes: 68 additions & 0 deletions
68
medmodels/statistic_evaluations/comparer/data_comparer.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any, Dict, List, Optional, Tuple, Union | ||
|
||
import polars as pl | ||
|
||
from medmodels.medrecord.medrecord import MedRecord | ||
from medmodels.medrecord.types import ( | ||
Group, | ||
GroupInputList, | ||
MedRecordAttribute, | ||
MedRecordAttributeInputList, | ||
) | ||
from medmodels.medrecord.querying import NodeOperation | ||
from medmodels.statistic_evaluations.comparer.builder import ComparerBuilder | ||
|
||
class DataComparer: | ||
Check failure on line 17 in medmodels/statistic_evaluations/comparer/data_comparer.pyi GitHub Actions / lintRuff (I001)
|
||
|
||
patients_group: Group | ||
time_attribute: MedRecordAttribute | ||
concept_group: Union[GroupInputList, Group] | ||
top_k_concepts: int | ||
alpha: float | ||
subpopulations_groups: Optional[GroupInputList] | ||
subpopulations_queries: Optional[List[NodeOperation]] | ||
control_population: Optional[Union[Group, NodeOperation]] | ||
|
||
@classmethod | ||
def builder(cls) -> ComparerBuilder: ... | ||
@staticmethod | ||
def _set_configuration( | ||
data_comparer: DataComparer, | ||
*, | ||
patient_group: Group = "patients", | ||
time_attribute: MedRecordAttribute = "time", | ||
concept_group: Union[GroupInputList, Group] = "concepts", | ||
top_k_concepts: int = 10, | ||
alpha: float = 0.05, | ||
subpopulations_groups: Optional[GroupInputList], | ||
subpopulations_queries: Optional[List[NodeOperation]], | ||
control_population: Optional[Union[Group, NodeOperation]], | ||
) -> None: ... | ||
def compare_attributes( | ||
self, | ||
medrecords: List[MedRecord], | ||
attributes: MedRecordAttributeInputList, | ||
) -> Dict[MedRecordAttribute, pl.DataFrame]: ... | ||
def calculate_absolute_relative_difference( | ||
self, | ||
medrecords: Union[MedRecord, List[MedRecord]], | ||
attributes: MedRecordAttributeInputList, | ||
control_data: Optional[MedRecord], | ||
) -> Tuple[float, pl.DataFrame]: ... | ||
def test_difference_attributes( | ||
self, | ||
medrecords: Union[MedRecord, List[MedRecord]], | ||
attributes: MedRecordAttributeInputList, | ||
) -> Dict[MedRecordAttribute, Tuple[float, float]]: ... | ||
def get_top_k_concepts( | ||
self, | ||
medrecord: MedRecord, | ||
) -> Dict[Union[Group, str], List[Any]]: ... | ||
def calculate_distance_concepts( | ||
self, medrecord: Union[List[MedRecord], MedRecord] | ||
) -> Dict[str, float]: ... | ||
def full_report( | ||
self, medrecord: Union[MedRecord, List[MedRecord]] | ||
) -> Dict[str, Any]: ... |