whylogs.core.metrics#

Submodules#

Package Contents#

Classes#

ColumnCountsMetric

TypeCountersMetric

ConditionCountMetric

CardinalityMetric

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

FrequentItemsMetric

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

Metric

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

MetricConfig

UnicodeRangeMetric

For string values, maintains a DistributionMetric for the counts of

StandardMetric

Generic enumeration.

class whylogs.core.metrics.ColumnCountsMetric#

Bases: whylogs.core.metrics.metrics.Metric

property namespace: str#
Return type

str

n: whylogs.core.metrics.metric_components.IntegralComponent#
null: whylogs.core.metrics.metric_components.IntegralComponent#
nan: whylogs.core.metrics.metric_components.IntegralComponent#
inf: whylogs.core.metrics.metric_components.IntegralComponent#
columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) whylogs.core.metrics.metrics.OperationResult#
Parameters

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

whylogs.core.metrics.metrics.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[whylogs.core.metrics.metrics.MetricConfig] = None) ColumnCountsMetric#
Parameters

config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –

Return type

ColumnCountsMetric

class whylogs.core.metrics.TypeCountersMetric#

Bases: whylogs.core.metrics.metrics.Metric

property namespace: str#
Return type

str

integral: whylogs.core.metrics.metric_components.IntegralComponent#
fractional: whylogs.core.metrics.metric_components.IntegralComponent#
boolean: whylogs.core.metrics.metric_components.IntegralComponent#
string: whylogs.core.metrics.metric_components.IntegralComponent#
object: whylogs.core.metrics.metric_components.IntegralComponent#
tensor: whylogs.core.metrics.metric_components.IntegralComponent#
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]

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

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

whylogs.core.metrics.metrics.OperationResult

classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) TypeCountersMetric#
Parameters

config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –

Return type

TypeCountersMetric

class whylogs.core.metrics.ConditionCountMetric#

Bases: whylogs.core.metrics.metrics.Metric

property exclude_from_serialization: bool#
Return type

bool

property namespace: str#
Return type

str

conditions: Dict[str, Condition]#
total: whylogs.core.metrics.metric_components.IntegralComponent#
matches: Dict[str, whylogs.core.metrics.metric_components.IntegralComponent]#
hide_from_serialization: bool = False#
merge(other: ConditionCountMetric) ConditionCountMetric#
Parameters

other (ConditionCountMetric) –

Return type

ConditionCountMetric

add_conditions(conditions: Dict[str, Condition]) None#
Parameters

conditions (Dict[str, Condition]) –

Return type

None

get_component_paths() List[str]#
Return type

List[str]

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

data (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

whylogs.core.metrics.metrics.OperationResult

classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) ConditionCountMetric#
Parameters

config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –

Return type

ConditionCountMetric

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

whylogs.core.proto.MetricMessage

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 from_protobuf(msg: whylogs.core.proto.MetricMessage) ConditionCountMetric#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

ConditionCountMetric

class whylogs.core.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.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.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.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.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

class whylogs.core.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]#
class whylogs.core.metrics.UnicodeRangeMetric(submetrics: Dict[str, Dict[str, whylogs.core.metrics.Metric]])#

Bases: whylogs.core.metrics.multimetric.MultiMetric

For string values, maintains a DistributionMetric for the counts of characters that fall within user-defined codepoint ranges.

Parameters
range_definitionsDict[str, Tuple[int, int]]

Defines the character ranges to be counted. The key servers as the range name and should only contain alphanumeric, hyphen, and underscore characters. The tuple defines the Unicode codepoint range to be tracked. The string length is tracked under the key “STRING_LENGTH” so don’t use that as a range name.

Parameters

submetrics (Dict[str, Dict[str, whylogs.core.metrics.Metric]]) –

property namespace: str#
Return type

str

range_definitions: Dict[str, Tuple[int, int]]#
lower_case: bool = True#
normalize: bool = True#
submetrics: Dict[str, Dict[str, whylogs.core.metrics.Metric]]#
merge(other: UnicodeRangeMetric) UnicodeRangeMetric#
Parameters

other (UnicodeRangeMetric) –

Return type

UnicodeRangeMetric

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

view (whylogs.core.preprocessing.PreprocessedColumn) –

Return type

whylogs.core.metrics.metrics.OperationResult

classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) UnicodeRangeMetric#
Parameters

config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –

Return type

UnicodeRangeMetric

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

msg (whylogs.core.proto.MetricMessage) –

Return type

UnicodeRangeMetric

merge_submetrics(other: MULTI_METRIC) Dict[str, Dict[str, whylogs.core.metrics.Metric]]#
Parameters

other (MULTI_METRIC) –

Return type

Dict[str, Dict[str, whylogs.core.metrics.Metric]]

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

whylogs.core.proto.MetricMessage

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]

classmethod submetrics_from_protobuf(msg: whylogs.core.proto.MetricMessage) Dict[str, Dict[str, whylogs.core.metrics.Metric]]#
Parameters

msg (whylogs.core.proto.MetricMessage) –

Return type

Dict[str, Dict[str, whylogs.core.metrics.Metric]]

class whylogs.core.metrics.StandardMetric(clz: metrics.Metric)#

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

Parameters

clz (metrics.Metric) –

types#
distribution#
counts#
ints#
cardinality#
frequent_items#
unicode_range#
condition_count#
zero(config: Optional[metrics.MetricConfig] = None) metrics.Metric#
Parameters

config (Optional[metrics.MetricConfig]) –

Return type

metrics.Metric

name()#

The name of the Enum member.

value()#

The value of the Enum member.