whylogs.core.constraints.metric_constraints
#
Module Contents#
Classes#
Implements dataset-level constraints that require a reference dataset to |
|
Implements dataset-level constraints that are not attached to a specific |
|
Converts a MetricConstraint not associated with a specific column |
|
Interpret expressions in the form used to serialize Predicate expressions. |
|
Functions#
|
Attributes#
- whylogs.core.constraints.metric_constraints.logger#
- whylogs.core.constraints.metric_constraints.ReportResult#
- class whylogs.core.constraints.metric_constraints.MetricsSelector#
-
- metrics_resolver: Optional[Callable[[whylogs.core.view.dataset_profile_view.DatasetProfileView], List[whylogs.core.metrics.metrics.Metric]]]#
- column_profile(profile: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) Optional[whylogs.core.view.column_profile_view.ColumnProfileView] #
- Parameters
profile (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- Return type
Optional[whylogs.core.view.column_profile_view.ColumnProfileView]
- apply(profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) List[whylogs.core.metrics.metrics.Metric] #
- Parameters
profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- whylogs.core.constraints.metric_constraints.pretty_display(metric_name: str, summary: Dict[str, Any]) Dict[str, Any] #
- class whylogs.core.constraints.metric_constraints.MetricConstraint#
- condition: Callable[[whylogs.core.metrics.metrics.Metric], bool]#
- metric_selector: MetricsSelector#
- validate(dataset_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) bool #
- Parameters
dataset_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- validate_profile(dataset_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) Tuple[bool, Optional[Dict[str, Any]]] #
- Parameters
dataset_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- exception whylogs.core.constraints.metric_constraints.MissingMetric#
Bases:
Exception
DatasetConstraint conditions can raise this exception to indicate that a required metric or column could not be found in the DatasetProfileView. The DatasetConstraint is responsible for handling this exception.
- class args#
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class whylogs.core.constraints.metric_constraints.DatasetComparisonConstraint#
Implements dataset-level constraints that require a reference dataset to be compared against. The condition Callable takes the DatasetProfileView of the dataset to be validated as well as the DatasetProfileView of the reference dataset and returns a boolean indicating whether the condition is satisfied as well as a dictionary with summary information about the validation.
- condition: Callable[[whylogs.core.view.dataset_profile_view.DatasetProfileView, whylogs.core.view.dataset_profile_view.DatasetProfileView], Tuple[bool, Dict[str, whylogs.core.metrics.metrics.Metric]]]#
- validate_profile(dataset_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView, reference_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) Tuple[bool, Optional[Dict[str, Any]]] #
- Parameters
dataset_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
reference_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- class whylogs.core.constraints.metric_constraints.DatasetConstraint#
Implements dataset-level constraints that are not attached to a specific metric or column. The condition Callable takes the DatasetProfileView as input and returns a boolean indicating whether the condition is satisfied as well as a dictionary mapping ‘column_name/metric_namespace’ -> Metric for any metrics the condition used during its evaluation.
- condition: Callable[[whylogs.core.view.dataset_profile_view.DatasetProfileView], Tuple[bool, Dict[str, whylogs.core.metrics.metrics.Metric]]]#
- validate_profile(dataset_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) Tuple[bool, Optional[Dict[str, Any]]] #
- Parameters
dataset_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- class whylogs.core.constraints.metric_constraints.MetricConstraintWrapper(constraint: MetricConstraint)#
Converts a MetricConstraint not associated with a specific column into a Callable that can be a DatasetConstraint condition.
- Parameters
constraint (MetricConstraint) –
- class whylogs.core.constraints.metric_constraints.PrefixCondition(expression: str, cfg: Optional[whylogs.core.configs.SummaryConfig] = None)#
Interpret expressions in the form used to serialize Predicate expressions. This is probably a reasonable serialization format for DatasetConstraint conditions, but might not be the best user interface for creating conditions in client code.
- Parameters
expression (str) –
cfg (Optional[whylogs.core.configs.SummaryConfig]) –
- class whylogs.core.constraints.metric_constraints.Constraints(dataset_profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None, column_constraints: Optional[Dict[str, Dict[str, MetricConstraint]]] = None, reference_profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None)#
- Parameters
dataset_profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
column_constraints (Optional[Dict[str, Dict[str, MetricConstraint]]]) –
reference_profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- column_constraints: Dict[str, Dict[str, MetricConstraint]]#
- dataset_constraints: List[DatasetConstraint]#
- dataset_comparison_constraints: List[DatasetComparisonConstraint]#
- dataset_profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]#
- validate(profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None) bool #
- Parameters
profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- Return type
- set_reference_profile_view(profile_view: whylogs.core.view.dataset_profile_view.DatasetProfileView) None #
- Parameters
profile_view (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
- Return type
- report(profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None) List[Tuple[str, int, int]] #
- Parameters
profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- Return type
- generate_constraints_report(profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None, with_summary=False) List[ReportResult] #
- Parameters
profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- Return type
List[ReportResult]
- class whylogs.core.constraints.metric_constraints.ConstraintsBuilder(dataset_profile_view: whylogs.core.view.dataset_profile_view.DatasetProfileView, constraints: Optional[Constraints] = None, reference_profile_view: Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView] = None)#
- Parameters
dataset_profile_view (whylogs.core.view.dataset_profile_view.DatasetProfileView) –
constraints (Optional[Constraints]) –
reference_profile_view (Optional[whylogs.core.view.dataset_profile_view.DatasetProfileView]) –
- get_metric_selectors() List[MetricsSelector] #
- Return type
List[MetricsSelector]
- add_constraints(constraints: List[Union[MetricConstraint, DatasetConstraint]]) ConstraintsBuilder #
- Parameters
constraints (List[Union[MetricConstraint, DatasetConstraint]]) –
- Return type
- add_constraint(constraint: Union[MetricConstraint, DatasetConstraint], ignore_missing: bool = False) ConstraintsBuilder #
- Parameters
constraint (Union[MetricConstraint, DatasetConstraint]) –
ignore_missing (bool) –
- Return type
- build() Constraints #
- Return type