whylogs.core.metrics.metrics#

Module Contents#

Classes#

MetricConfig

OperationResult

Metric

Helper class that provides a standard way to create an ABC using

IntsMetric

Helper class that provides a standard way to create an ABC using

DistributionMetric

Helper class that provides a standard way to create an ABC using

FrequentItem

FrequentItemsMetric

Helper class that provides a standard way to create an ABC using

CardinalityMetric

Helper class that provides a standard way to create an ABC using

CustomMetricBase

You can use this as a base class for custom metrics that don't use

CardinalityThresholds

Functions#

custom_metric(→ Type[METRIC])

register_metric(→ None)

Attributes#

whylogs.core.metrics.metrics.T#
whylogs.core.metrics.metrics.M#
whylogs.core.metrics.metrics.NUM#
whylogs.core.metrics.metrics.METRIC#
class whylogs.core.metrics.metrics.MetricConfig#
hll_lg_k: int#
kll_k: int#
fi_lg_max_k: int#
fi_disabled: bool#
track_unicode_ranges: bool#
large_kll_k: bool#
kll_k_large: int#
unicode_ranges: Dict[str, Tuple[int, int]]#
lower_case: bool#
normalize: bool#
max_frequent_item_size: int#
identity_column: Optional[str]#
whylogs.core.metrics.metrics.custom_metric(metric: Type[METRIC]) Type[METRIC]#
Parameters

metric (Type[METRIC]) –

Return type

Type[METRIC]

class whylogs.core.metrics.metrics.OperationResult#
failures: int = 0#
successes: int = 0#
classmethod ok(cnt: int = 1) OperationResult#
Parameters

cnt (int) –

Return type

OperationResult

classmethod failed(cnt: int = 1) OperationResult#
Parameters

cnt (int) –

Return type

OperationResult

class whylogs.core.metrics.metrics.Metric#

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

property exclude_from_serialization: bool#
Return type

bool

abstract property namespace: str#
Return type

str

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

merge(other: METRIC) METRIC#
Parameters

other (METRIC) –

Return type

METRIC

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

get_component_paths() List[str]#
Return type

List[str]

abstract to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Any]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Any]

abstract columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#
Parameters

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

OperationResult

abstract classmethod zero(config: Optional[MetricConfig] = None) METRIC#
Parameters

config (Optional[MetricConfig]) –

Return type

METRIC

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

whylogs.core.metrics.metrics.register_metric(metrics: Union[Metric, Type[METRIC], List[Metric], List[Type[METRIC]]]) None#
Parameters

metrics (Union[Metric, Type[METRIC], List[Metric], List[Type[METRIC]]]) –

Return type

None

class whylogs.core.metrics.metrics.IntsMetric#

Bases: Metric

Helper class that provides a standard way to create an ABC using inheritance.

property namespace: str#
Return type

str

property maximum: float#
Return type

float

property minimum: float#
Return type

float

property exclude_from_serialization: bool#
Return type

bool

max: whylogs.core.metrics.metric_components.MaxIntegralComponent#
min: whylogs.core.metrics.metric_components.MinIntegralComponent#
columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#
Parameters

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

OperationResult

classmethod zero(config: Optional[MetricConfig] = None) IntsMetric#
Parameters

config (Optional[MetricConfig]) –

Return type

IntsMetric

to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Union[int, float, str, None]]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Union[int, float, str, None]]

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

merge(other: METRIC) METRIC#
Parameters

other (METRIC) –

Return type

METRIC

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

get_component_paths() List[str]#
Return type

List[str]

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

class whylogs.core.metrics.metrics.DistributionMetric#

Bases: Metric

Helper class that provides a standard way to create an ABC using inheritance.

property namespace: str#
Return type

str

property n: float#
Return type

float

property variance: float#

Returns the sample variance of the stream.

https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford’s_online_algorithm

Return type

float

property stddev: float#
Return type

float

property avg: float#
Return type

float

property median: Optional[float]#
Return type

Optional[float]

property q_01: Optional[float]#
Return type

Optional[float]

property q_05: Optional[float]#
Return type

Optional[float]

property q_10: Optional[float]#
Return type

Optional[float]

property q_25: Optional[float]#
Return type

Optional[float]

property q_75: Optional[float]#
Return type

Optional[float]

property q_90: Optional[float]#
Return type

Optional[float]

property q_95: Optional[float]#
Return type

Optional[float]

property q_99: Optional[float]#
Return type

Optional[float]

property max: float#
Return type

float

property min: float#
Return type

float

property exclude_from_serialization: bool#
Return type

bool

kll: whylogs.core.metrics.metric_components.KllComponent#
mean: whylogs.core.metrics.metric_components.FractionalComponent#
m2: whylogs.core.metrics.metric_components.FractionalComponent#
to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Union[int, float, str, None]]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Union[int, float, str, None]]

columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#

Update the operation

Algorithm: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm

Parameters

view (whylogs.core.preprocessing.PreprocessedColumn) – the preprocessed column

Returns

how many successful operations we had

Return type

OperationResult

merge(other: DistributionMetric) DistributionMetric#
Parameters

other (DistributionMetric) –

Return type

DistributionMetric

get_quantile(quantile: float) Optional[float]#
Parameters

quantile (float) –

Return type

Optional[float]

classmethod zero(config: Optional[MetricConfig] = None) DistributionMetric#
Parameters

config (Optional[MetricConfig]) –

Return type

DistributionMetric

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

get_component_paths() List[str]#
Return type

List[str]

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

class whylogs.core.metrics.metrics.FrequentItem#
value: str#
est: int#
upper: int#
lower: int#
class whylogs.core.metrics.metrics.FrequentItemsMetric#

Bases: Metric

Helper class that provides a standard way to create an ABC using inheritance.

property namespace: str#
Return type

str

property strings: List[FrequentItem]#
Return type

List[FrequentItem]

property exclude_from_serialization: bool#
Return type

bool

frequent_strings: whylogs.core.metrics.metric_components.FrequentStringsComponent#
max_frequent_item_size: int = 128#
columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#
Parameters

view (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

OperationResult

to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Any]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Any]

classmethod zero(config: Optional[MetricConfig] = None) FrequentItemsMetric#
Parameters

config (Optional[MetricConfig]) –

Return type

FrequentItemsMetric

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

merge(other: METRIC) METRIC#
Parameters

other (METRIC) –

Return type

METRIC

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

get_component_paths() List[str]#
Return type

List[str]

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

class whylogs.core.metrics.metrics.CardinalityMetric#

Bases: Metric

Helper class that provides a standard way to create an ABC using inheritance.

property namespace: str#
Return type

str

property estimate: Optional[float]#
Return type

Optional[float]

property upper_1: Optional[float]#
Return type

Optional[float]

property lower_1: Optional[float]#
Return type

Optional[float]

property exclude_from_serialization: bool#
Return type

bool

hll: whylogs.core.metrics.metric_components.HllComponent#
columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#
Parameters

view (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

OperationResult

to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Any]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Any]

get_upper_bound(number_of_standard_deviations: int) Optional[float]#
Parameters

number_of_standard_deviations (int) –

Return type

Optional[float]

get_lower_bound(number_of_standard_deviations: int) Optional[float]#
Parameters

number_of_standard_deviations (int) –

Return type

Optional[float]

classmethod zero(config: Optional[MetricConfig] = None) CardinalityMetric#
Parameters

config (Optional[MetricConfig]) –

Return type

CardinalityMetric

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

merge(other: METRIC) METRIC#
Parameters

other (METRIC) –

Return type

METRIC

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

get_component_paths() List[str]#
Return type

List[str]

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

class whylogs.core.metrics.metrics.CustomMetricBase#

Bases: Metric, abc.ABC

You can use this as a base class for custom metrics that don’t use the supplied or custom MetricComponents. Subclasses must be decorated with @dataclass. All fields not prefixed with an underscore will be included in the summary and will be [de]serialized. Such subclasses will need to implement the namespace, merge, and zero methods. They should be registered by calling register_metric()

property exclude_from_serialization: bool#
Return type

bool

abstract property namespace: str#
Return type

str

get_component_paths() List[str]#
Return type

List[str]

to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Any]#
Parameters

cfg (Optional[whylogs.core.configs.SummaryConfig]) –

Return type

Dict[str, Any]

to_protobuf() whylogs.core.proto.MetricMessage#
Return type

whylogs.core.proto.MetricMessage

classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) METRIC#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

METRIC

classmethod get_namespace(config: Optional[MetricConfig] = None) str#
Parameters

config (Optional[MetricConfig]) –

Return type

str

merge(other: METRIC) METRIC#
Parameters

other (METRIC) –

Return type

METRIC

abstract columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) OperationResult#
Parameters

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

OperationResult

abstract classmethod zero(config: Optional[MetricConfig] = None) METRIC#
Parameters

config (Optional[MetricConfig]) –

Return type

METRIC

class whylogs.core.metrics.metrics.CardinalityThresholds#
few: int = 50#
proportionately_few: float = 0.01#