rhino_health.lib.metrics.base_metric#

Module Contents#

Classes#

DataFilter

A filter to be applied on the entire Dataset

GroupingData

Configuration for grouping metric results

MetricResponse

Standardized response from querying metrics against a Dataset

KaplanMeierMetricResponse

Standardized response from querying metrics against a Dataset

TwoByTwoTableMetricResponse

Standardized response from querying metrics against a Dataset

BaseMetric

Parameters available for every metric

JoinMode

The mode we are performing the FederatedJoin

Attributes#

MetricResultDataType

Dict[str, Any]

class rhino_health.lib.metrics.base_metric.DataFilter(**data: Any)#

Bases: pydantic.BaseModel

A filter to be applied on the entire Dataset

filter_column: str#

The column in the remote dataset df to check against

filter_value: Any | rhino_health.lib.metrics.filter_variable.FilterBetweenRange#

The value to match against or a FilterBetweenRange if filter_type is FilterType.BETWEEN

filter_type: rhino_health.lib.metrics.filter_variable.FilterType | None#

The type of filtering to perform. Defaults to FilterType.EQUAL

filter_dataset: str | None#

The dataset to perform the filter on if there are multiple datasets for Federated Join. If unspecified will be all datasets

class rhino_health.lib.metrics.base_metric.GroupingData(**data: Any)#

Bases: pydantic.BaseModel

Configuration for grouping metric results

See also

pandas.groupby

Implementation used for grouping. See documentation

groupings: List[str] = []#

A list of columns to group metric results by

dropna: bool | None = True#

Should na values be dropped if in a grouping key

rhino_health.lib.metrics.base_metric.MetricResultDataType#

Dict[str, Any]

class rhino_health.lib.metrics.base_metric.MetricResponse(**data)#

Bases: pydantic.BaseModel

Standardized response from querying metrics against a Dataset

output: MetricResultDataType#
metric_configuration_dict: Dict[str, Any] | None#
class rhino_health.lib.metrics.base_metric.KaplanMeierMetricResponse(**data)#

Bases: MetricResponse

Standardized response from querying metrics against a Dataset

time_variable: str#
event_variable: str#
surv_func_right_model(group=None)#

Creates a survival function model for the metric response

class rhino_health.lib.metrics.base_metric.TwoByTwoTableMetricResponse(**data)#

Bases: MetricResponse

Standardized response from querying metrics against a Dataset

as_table()#

Display the 2X2 table metric response as a dict representing a table. Use pd.DataFrame(as_table_result) to visualize the table. The data provided should represent a 2X2 table meaning the dict is of length 4, the keys should be tuples of length 2 representing the possible combination of values. The “detected” values are the columns and the “exposed” values are the rows. If the data is boolean, the table order is (true, false) for both columns and rows. If not, the order is alphabetical.

static get_ordered_dict_table(table_data: dict)#

Returns the table data as an ordered dict representing a table. The data provided should represent a 2X2 table meaning the dict is of length 4, the keys should be tuples of length 2 representing the possible combination of values. The “detected” values are the columns and the “exposed” values are the rows. If the data is boolean, the table order is (true, false) for both columns and rows. If not, the order is alphabetical.

class rhino_health.lib.metrics.base_metric.BaseMetric(**data: Any)#

Bases: pydantic.BaseModel

Parameters available for every metric

property metric_response#
data_filters: List[DataFilter] | None = []#
group_by: GroupingData | None#
timeout_seconds: float | None = 600.0#
count_variable_name: str = 'variable'#
data()#
class rhino_health.lib.metrics.base_metric.JoinMode#

Bases: str, enum.Enum

The mode we are performing the FederatedJoin

INTERSECTION = 'intersection'#

Return values where the identifiers are found in both the filter and query datasets.

UNION = 'union'#

Returns values where rows with the same identifiers are deduplicated.