whylogs.core.metrics
#
Submodules#
whylogs.core.metrics.aggregators
whylogs.core.metrics.column_metrics
whylogs.core.metrics.compound_metric
whylogs.core.metrics.condition_count_metric
whylogs.core.metrics.decorators
whylogs.core.metrics.deserializers
whylogs.core.metrics.maths
whylogs.core.metrics.metric_components
whylogs.core.metrics.metrics
whylogs.core.metrics.multimetric
whylogs.core.metrics.serializers
whylogs.core.metrics.unicode_range
Package Contents#
Classes#
A whylogs metric that counts how many column entries satisfy a condition. |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
For string values, maintains a DistributionMetric for the counts of |
|
Generic enumeration. |
- class whylogs.core.metrics.ColumnCountsMetric#
Bases:
whylogs.core.metrics.metrics.Metric
- columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) whylogs.core.metrics.metrics.OperationResult #
- Parameters
- Return type
- 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
- class whylogs.core.metrics.TypeCountersMetric#
Bases:
whylogs.core.metrics.metrics.Metric
- 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
- Return type
- classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) TypeCountersMetric #
- Parameters
config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –
- Return type
- class whylogs.core.metrics.ConditionCountMetric#
Bases:
whylogs.core.metrics.metrics.Metric
A whylogs metric that counts how many column entries satisfy a condition.
- Parameters
conditions (Dict[str, Condition]) – The conditions evaluated by the metric. The key is the condition name, and the Condition value specifies the Callable condition predicate to evaluate & count.
Examples
This example counts the occurrances of email addresses in the some_text column and credit card numbers in the more_text column.
``` import pandas as pd import whylogs as why from whylogs.core.resolvers import STANDARD_RESOLVER from whylogs.core.specialized_resolvers import ConditionCountMetricSpec from whylogs.core.metrics.condition_count_metric import Condition from whylogs.core.relations import Predicate from whylogs.core.schema import DeclarativeSchema
email_condition = {“contiansEmail”: Condition(Predicate().fullmatch(“[w.]+[._]?[a-z0-9]+[@]w+[.]w{2,3}”))} cc_condition = {“containsCreditCard”: Condition(Predicate().matches(“.*4[0-9]{12}(?:[0-9]{3})?”))}
schema = DeclarativeSchema(STANDARD_RESOLVER) schema.add_resolver_spec(column_name=”some_text”, metrics=[ConditionCountMetricSpec(email_condition)]) schema.add_resolver_spec(column_name=”more_text”, metrics=[ConditionCountMetricspec(cc_condition)])
df = pd.DataFrame({“some_text”: [“not an email”, “bob@spam.com”], “more_text”: [“frogs”, “4000000000000”]}) view = why.log(df).view() view.to_pandas()[[‘condition_count/containsEmail’, ‘condition_count/containsCreditCard’, ‘condition_count/total’]]
# results in
condition_count/containsEmail condition_count/containsCreditCard condition_count/total
column some_text 1.0 NaN 2 more_text NaN 1.0 2 ```
- matches: Dict[str, whylogs.core.metrics.metric_components.IntegralComponent]#
- merge(other: ConditionCountMetric) ConditionCountMetric #
- Parameters
other (ConditionCountMetric) –
- Return type
- columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) whylogs.core.metrics.metrics.OperationResult #
- Parameters
- Return type
- classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) ConditionCountMetric #
- Parameters
config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –
- Return type
- 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
- class whylogs.core.metrics.CardinalityMetric#
Bases:
Metric
Helper class that provides a standard way to create an ABC using inheritance.
- columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) OperationResult #
- Parameters
- Return type
- 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) CardinalityMetric #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- merge(other: METRIC) METRIC #
- Parameters
other (METRIC) –
- Return type
METRIC
- 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
- class whylogs.core.metrics.DistributionMetric#
Bases:
Metric
Helper class that provides a standard way to create an ABC using inheritance.
- 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
- to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) 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
- merge(other: DistributionMetric) DistributionMetric #
- Parameters
other (DistributionMetric) –
- Return type
- classmethod zero(config: Optional[MetricConfig] = None) DistributionMetric #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- 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
- class whylogs.core.metrics.FrequentItemsMetric#
Bases:
Metric
Helper class that provides a standard way to create an ABC using inheritance.
- property strings: List[FrequentItem]#
- Return type
List[FrequentItem]
- frequent_strings: whylogs.core.metrics.metric_components.FrequentStringsComponent#
- columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) OperationResult #
- Parameters
- Return type
- 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
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- merge(other: METRIC) METRIC #
- Parameters
other (METRIC) –
- Return type
METRIC
- 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
- class whylogs.core.metrics.IntsMetric#
Bases:
Metric
Helper class that provides a standard way to create an ABC using inheritance.
- columnar_update(data: whylogs.core.preprocessing.PreprocessedColumn) OperationResult #
- Parameters
- Return type
- classmethod zero(config: Optional[MetricConfig] = None) IntsMetric #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Union[int, float, str, None]] #
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- merge(other: METRIC) METRIC #
- Parameters
other (METRIC) –
- Return type
METRIC
- 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
- class whylogs.core.metrics.Metric#
Bases:
abc.ABC
Helper class that provides a standard way to create an ABC using inheritance.
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- merge(other: METRIC) METRIC #
- Parameters
other (METRIC) –
- Return type
METRIC
- to_protobuf() whylogs.core.proto.MetricMessage #
- Return type
whylogs.core.proto.MetricMessage
- 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
- Return type
- 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#
- 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]]) –
- submetrics: Dict[str, Dict[str, whylogs.core.metrics.Metric]]#
- merge(other: UnicodeRangeMetric) UnicodeRangeMetric #
- Parameters
other (UnicodeRangeMetric) –
- Return type
- columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) whylogs.core.metrics.metrics.OperationResult #
- Parameters
- Return type
- classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) UnicodeRangeMetric #
- Parameters
config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –
- Return type
- classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) UnicodeRangeMetric #
- Parameters
msg (whylogs.core.proto.MetricMessage) –
- Return type
- 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
- 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
- name()#
The name of the Enum member.
- value()#
The value of the Enum member.