Skip to content

Commit

Permalink
added interface for comparer and builder
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBoenchenLB committed Sep 11, 2024
1 parent 0083cd8 commit b3b4afc
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
34 changes: 34 additions & 0 deletions medmodels/statistic_evaluations/comparer/builder.pyi
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

View workflow job for this annotation

GitHub Actions / lint

Ruff (I001)

medmodels/statistic_evaluations/comparer/builder.pyi:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 9 in medmodels/statistic_evaluations/comparer/builder.pyi

View workflow job for this annotation

GitHub Actions / lint

Ruff (I001)

medmodels/statistic_evaluations/comparer/builder.pyi:1:1: I001 Import block is un-sorted or un-formatted
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 medmodels/statistic_evaluations/comparer/data_comparer.pyi
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

View workflow job for this annotation

GitHub Actions / lint

Ruff (I001)

medmodels/statistic_evaluations/comparer/data_comparer.pyi:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 17 in medmodels/statistic_evaluations/comparer/data_comparer.pyi

View workflow job for this annotation

GitHub Actions / lint

Ruff (I001)

medmodels/statistic_evaluations/comparer/data_comparer.pyi:1:1: I001 Import block is un-sorted or un-formatted

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]: ...

0 comments on commit b3b4afc

Please sign in to comment.