* ChainedInequality
The ChainedInequality constraint enforces a chain of inequality relationships between any number of columns. For every row, the value in these columns must follow a strict ordering system.
Constraint API
Create a ChainedInequality
constraint.
Parameters:
(required)
column_names
: A list of strings that represent the column names. They should appear in ascending order (lowest to highest). Only numerical and datetime columns are allowed.strict_boundaries
: Whether a column must be strictly greater than previous one(default)
True
: The value in the higher column must be strictly greater than the lower oneFalse
: The value in the higher column must be greater than or equal to the value of the lower one
table_name
: A string with the name of the table to apply this to. Required if you have a multi-table dataset.
from sdv.cag import ChainedInequality
my_constraint = ChainedInequality(
column_names=['purchase_date', 'start_date', 'end_date', 'expiration_date']
)
Usage
Apply the constraint to any SDV synthesizer. Then fit and sample as usual.
synthesizer = GaussianCopulaSynthesizer(metadata)
synthesizer.add_constraints([my_constraint])
synthesizer.fit(data)
synthetic_data = synthesizer.sample()
For more information about using predefined constraints, please see the Constraint-Augmented Generation tutorial.
Last updated