From 5b7103ae30d2d0271ba0343752fcd5a59a30f95f Mon Sep 17 00:00:00 2001 From: Laura Boenchen Date: Wed, 9 Oct 2024 14:00:05 +0200 Subject: [PATCH] added attribute dict to Cohort class --- medmodels/medrecord/types.py | 2 +- .../comparer/data_comparer.pyi | 52 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/medmodels/medrecord/types.py b/medmodels/medrecord/types.py index 7d354886..ac46ef93 100644 --- a/medmodels/medrecord/types.py +++ b/medmodels/medrecord/types.py @@ -89,7 +89,7 @@ PandasEdgeDataFrameInput: TypeAlias = Tuple[pd.DataFrame, str, str] AttributeInfo: TypeAlias = Union[ - TemporalAttributeInfo, NumericAttributeInfo, StringAttributeInfo + "TemporalAttributeInfo", "NumericAttributeInfo", "StringAttributeInfo" ] diff --git a/medmodels/statistic_evaluations/comparer/data_comparer.pyi b/medmodels/statistic_evaluations/comparer/data_comparer.pyi index 72952105..d15a8759 100644 --- a/medmodels/statistic_evaluations/comparer/data_comparer.pyi +++ b/medmodels/statistic_evaluations/comparer/data_comparer.pyi @@ -10,7 +10,6 @@ from medmodels.medrecord.types import ( Group, GroupInputList, MedRecordAttribute, - MedRecordAttributeInputList, NodeIndex, ) @@ -26,7 +25,8 @@ class Cohort: name: str cohort_group: Group time_attribute: MedRecordAttribute - concepts_groups: GroupInputList + attributes: Optional[Dict[str, MedRecordAttribute]] + concepts_groups: Optional[GroupInputList] def __init__( self, @@ -34,6 +34,7 @@ class Cohort: name: str, cohort_group: Union[Group, NodeOperation] = "patients", time_attribute: MedRecordAttribute = "time", + attributes: Optional[Dict[str, MedRecordAttribute]] = None, concepts_groups: Optional[GroupInputList] = None, ) -> None: ... @@ -41,7 +42,7 @@ class CohortSummary(TypedDict): """Dictionary for the cohort summary.""" attribute_info: Dict[Group, AttributeSummary] - top_concepts: Dict[Group, List[NodeIndex]] + top_k_concepts: Dict[Group, List[NodeIndex]] class DistanceSummary(TypedDict): """Dictonary for the Jensen-Shannon-Divergence and normalized distance between @@ -53,8 +54,8 @@ class DistanceSummary(TypedDict): class ComparerSummary(TypedDict): """Dictionary for the comparing results.""" - attribute_tests: Dict[MedRecordAttribute, TestSummary] - concepts_tests: Dict[Group, TestSummary] + attribute_tests: Dict[MedRecordAttribute, List[TestSummary]] + concepts_tests: Dict[Group, List[TestSummary]] concepts_distance: Dict[Group, DistanceSummary] class TestSummary(TypedDict): @@ -64,45 +65,44 @@ class TestSummary(TypedDict): p_value: float class DataComparer: + @staticmethod + def compare_cohort_attribute( + cohorts_attribute: List[Tuple[Cohort, MedRecordAttribute]], + ) -> Dict[str, AttributeInfo]: ... + @staticmethod + def test_difference_attribute( + cohorts_attribute: List[Tuple[Cohort, MedRecordAttribute]], + significance_level: float, + ) -> List[TestSummary]: ... @staticmethod def compare_cohorts( cohorts: List[Cohort], - ) -> Dict[Group, CohortSummary]: ... + ) -> Dict[str, CohortSummary]: ... @staticmethod - def compare_cohort_attributes( - medrecords: List[Cohort], - attributes: MedRecordAttributeInputList, - ) -> Dict[ - Group, - Dict[MedRecordAttribute, AttributeInfo], - ]: ... + def test_difference_cohort_attributes( + cohorts: List[Cohort], + significance_level: float, + ) -> Dict[str, List[TestSummary]]: ... @staticmethod def calculate_absolute_relative_difference( - control_cohort: Cohort, - cohorts: List[Cohort], - attributes: MedRecordAttributeInputList, + control_group: Cohort, + case_groups: List[Cohort], ) -> Tuple[float, Dict[MedRecordAttribute, float]]: ... @staticmethod - def test_difference_attributes( - cohorts: List[Cohort], - attributes: MedRecordAttributeInputList, - significance_level: float, - ) -> Dict[MedRecordAttribute, TestSummary]: ... + def get_concept_counts( + cohort: Cohort, + ) -> List[Tuple[NodeIndex, int]]: ... @staticmethod def get_top_k_concepts( cohort: Cohort, top_k: int, ) -> List[NodeIndex]: ... @staticmethod - def get_concept_counts( - cohort: Cohort, - ) -> List[Tuple[NodeIndex, int]]: ... - @staticmethod def test_difference_top_k_concepts( cohorts: List[Cohort], top_k: int, significance_level: float, - ) -> Dict[Group, TestSummary]: ... + ) -> Dict[Group, List[TestSummary]]: ... @staticmethod def calculate_distance_concepts( cohorts: List[Cohort],