Constraints
Last updated
Last updated
Do you have rules that every row in the data must follow? Are these the same regardless of how much data there is? You can use constraints to describe this business logic to your synthesizer.
The SDV library comes with some predefined constraint logic that is ready to use. You can define each constraint using a dictionary format.
(required) 'constraint_class
: A string with the name of the predefined constraint class
(required) 'constraint_parameters'
: A dictionary with the parameters. Each class has different parameters.
Apply constraints by adding them to your synthesizer. Use this function to add your constraints to the synthesizer.
Parameters
(required) constraints
: A list of dictionaries that describe your constraint. These can be predefined constraints or your own, custom constraint.
Output (None)
Use this function to inspect all of the constraints your synthesizer contains.
Parameters None
Output A list of dictionaries that describe all the constraints applied to your synthesizer
After adding constraints, you'll need to (re)train the synthesizer with real data.
The synthesizer will now learn from your real data with the added constraints. All synthetic data it produces will be valid for the constraint.
Use this function to load your custom logic from a separate Python file.
Parameters
(required) filepath
: A string describing the filepath of your Python file. If your constraints are defined in the current file, you can specify None
.
(required) class_names
: A list of strings, describing the class names to load
Output (None) After using this function, you can apply your custom constraints to your synthesizer.
Once you have loaded your custom logic, you can define constraints using your custom name and parameters. Then you can apply it to your synthesizer just like any other constraint.
In some cases, you may need to add some custom constraints. We recommend you define the logic in a separate Python file. See the for more details.