whylogs.experimental.constraints_generation#

Submodules#

Package Contents#

Classes#

MetricConstraint

DatasetProfileView

A Writable is an object that contains data to write to a file or files.

Functions#

generate_column_condition_count_constraints(...)

Generates constraints for the condition count metrics of a column.

generate_column_count_constraints(...)

Generates constraints for the count metrics of a column.

generate_column_distribution_constraints(...)

Generates constraints for the count metrics of a column.

generate_column_frequent_items_constraints(...)

generate_column_multi_metrics_constraints(...)

generate_column_types_constraints(...)

Generates constraints for the types metrics of a column.

generate_constraints_from_reference_profile(...)

Generates constraints from a reference profile view.

class whylogs.experimental.constraints_generation.MetricConstraint#
condition: Callable[[whylogs.core.metrics.metrics.Metric], bool]#
name: str#
metric_selector: MetricsSelector#
require_column_existence: bool = True#
validate(dataset_profile: whylogs.core.view.dataset_profile_view.DatasetProfileView) bool#
Parameters

dataset_profile (whylogs.core.view.dataset_profile_view.DatasetProfileView) –

Return type

bool

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

Tuple[bool, Optional[Dict[str, Any]]]

class whylogs.experimental.constraints_generation.DatasetProfileView(*, columns: Dict[str, whylogs.core.view.column_profile_view.ColumnProfileView], dataset_timestamp: Optional[datetime.datetime], creation_timestamp: Optional[datetime.datetime], metrics: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, str]] = None)#

Bases: whylogs.api.writer.writer.Writable

A Writable is an object that contains data to write to a file or files. These might be temporary files intended to be passed on to another consumer (e.g., WhyLabs servers) via a Writer.

Parameters
property dataset_timestamp: Optional[datetime.datetime]#
Return type

Optional[datetime.datetime]

property creation_timestamp: Optional[datetime.datetime]#
Return type

Optional[datetime.datetime]

property metadata: Dict[str, str]#
Return type

Dict[str, str]

property model_performance_metrics: Any#
Return type

Any

add_model_performance_metrics(metric: Any) None#
Parameters

metric (Any) –

Return type

None

merge(other: DatasetProfileView) DatasetProfileView#
Parameters

other (DatasetProfileView) –

Return type

DatasetProfileView

get_column(col_name: str) Optional[whylogs.core.view.column_profile_view.ColumnProfileView]#
Parameters

col_name (str) –

Return type

Optional[whylogs.core.view.column_profile_view.ColumnProfileView]

get_columns(col_names: Optional[List[str]] = None) Dict[str, whylogs.core.view.column_profile_view.ColumnProfileView]#
Parameters

col_names (Optional[List[str]]) –

Return type

Dict[str, whylogs.core.view.column_profile_view.ColumnProfileView]

write(path: Optional[str] = None, filename: Optional[str] = None, **kwargs: Any) Tuple[bool, Union[str, List[str]]]#

Writes the Writable’s data to file(s) under path (excluding filename(s)) if specified, else under _get_default_path(). filename specifies the file to write there. Writables can generate a default filename if None is specified. Returns a bool that’s True iff all files were written successfully and a list of the filenames (including path) written.

Parameters
  • path (Optional[str]) –

  • filename (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, Union[str, List[str]]]

serialize() bytes#
Return type

bytes

classmethod zero() DatasetProfileView#
Return type

DatasetProfileView

classmethod deserialize(data: bytes) DatasetProfileView#
Parameters

data (bytes) –

Return type

DatasetProfileView

classmethod read(path: str) DatasetProfileView#
Parameters

path (str) –

Return type

DatasetProfileView

to_pandas(column_metric: Optional[str] = None, cfg: Optional[whylogs.core.configs.SummaryConfig] = None) whylogs.core.stubs.pd.DataFrame#
Parameters
Return type

whylogs.core.stubs.pd.DataFrame

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

whylogs.experimental.constraints_generation.generate_column_condition_count_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#

Generates constraints for the condition count metrics of a column. :param column_name: Name of the column :type column_name: str :param column_profile: Profile of the column :type column_profile: ColumnProfileView

Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_column_count_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#

Generates constraints for the count metrics of a column. :param column_name: Name of the column :type column_name: str :param column_profile: Profile of the column :type column_profile: ColumnProfileView

Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_column_distribution_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#

Generates constraints for the count metrics of a column. :param column_name: Name of the column :type column_name: str :param column_profile: Profile of the column :type column_profile: ColumnProfileView

Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_column_frequent_items_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#
Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_column_multi_metrics_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#
Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_column_types_constraints(column_name: str, column_profile: whylogs.core.view.column_profile_view.ColumnProfileView) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#

Generates constraints for the types metrics of a column. :param column_name: Name of the column :type column_name: str :param column_profile: Profile of the column :type column_profile: ColumnProfileView

Parameters
Return type

List[whylogs.core.constraints.metric_constraints.MetricConstraint]

whylogs.experimental.constraints_generation.generate_constraints_from_reference_profile(reference_profile_view: whylogs.core.view.dataset_profile_view.DatasetProfileView, included_columns: Optional[List[str]] = None, excluded_columns: Optional[List[str]] = None) List[whylogs.core.constraints.metric_constraints.MetricConstraint]#

Generates constraints from a reference profile view.

Parameters
  • reference_profile_view (DatasetProfileView) – Reference profile view

  • included_columns (Optional[List[str]], optional) – List of columns to include, by default None

  • excluded_columns (Optional[List[str]], optional) – List of columns to exclude, by default None

Returns

List of generated constraints

Return type

List[MetricConstraint]