For the complete documentation index, see llms.txt. This page is also available as Markdown.

ConstraintAdherence

This metric captures whether the synthetic data adheres to the business rules in your dataset, expressed as constraints.

What are constraints? Constraints are a way to describe business rules that appear in your dataset. For more information about how to represent constraints, as well as a list of possible constraints, please see the SDV documentation.

Data Compatibility

This metric is designed to work on any data column that is described by the constraint (involved in a business rule).

Score

(best) 1.0: All rows in the synthetic data respect the constraint.

(worst) 0.0: No rows in the synthetic data respect the constraint.

How does it work?

This metrics checks each data point in the synthetic data to see if it follows the constraint that is provided. The score the proportion of synthetic data data points that match the constraint definition.

Edge cases:

  • If the constraint cannot be checked for some reason (for example, the referenced table or column names don't exist in the data), then the metric will issue a warning and the score will be NaN.

  • If the real data does not match the constraint, then the metric will issue a warning but it will continue to check the synthetic data for adherence to the constraint.

  • The exact logic checked is based on the constraint, as defined in SDV. For more information, please see the SDV documentation.

  • Note that some constraints may not really have a logic. For example a DenormalizedTable with only the primary key (and no column names) doesn't have anything to check; in this case, the metric returns a score of 1.0.

Usage

To manually apply this metric, access the multi_table module and use the compute method.

Parameters

  • (required) real_data: A dictionary mapping the name of each table to a pandas.DataFrame containing the real data for that table.

  • (required) synthetic_data: A dictionary mapping the name of each table to a pandas.DataFrame containing the synthetic data for that table

  • (required) metadata: A dictionary describing the format, types of data and relationship between the tables. See Metadata for more details.

  • (required) constraint: A dictionary that defines the type of constraint and the parameters. This dictionary corresponds to a single constraint only and should follow the JSON definition from SDV. Typically, the class_name parameter is the full name of the constraint class, and the parameters dictionary maps each of the constraint parameters (key) to the value.

FAQs

Does this metric use real data?

If the real data doesn't match the provided constraint, then the metric will provide a warning but it will still continue to check the synthetic data.

Last updated