# sdv.constraints.Constraint¶

class sdv.constraints.Constraint(handling_strategy, fit_columns_model=False)[source]

Constraint base class.

This class is not intended to be used directly and should rather be subclassed to create different types of constraints.

If handling_strategy is passed with the value transform or reject_sampling, the filter_valid or transform and reverse_transform methods will be replaced respectively by a simple identity function.

constraint_columns

The names of the columns used by this constraint.

Type

tuple[str]

rebuild_columns

The names of the columns that this constraint will rebuild during reverse_transform.

Type

typle[str]

Parameters
• handling_strategy (str) – How this Constraint should be handled, which can be transform, reject_sampling or all.

• fit_columns_model (bool) – If False, reject sampling will be used to handle conditional sampling. Otherwise, a model will be trained and used to sample other columns based on the conditioned column.

__init__(handling_strategy, fit_columns_model=False)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

 __init__(handling_strategy[, fit_columns_model]) Initialize self. filter_valid(table_data) Get only the rows that are valid. fit(table_data) Fit Constraint class to data. fit_transform(table_data) Fit this Constraint to the data and then transform it. from_dict(constraint_dict) Build a Constraint object from a dict. is_valid(table_data) Say whether the given table rows are valid. reverse_transform(table_data) Identity method for completion. Return a dict representation of this Constraint. transform(table_data) Perform necessary transformations needed by constraint.

Attributes