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

Diagnostic

Diagnostic checks are meant to validate the basic data format and validity of the synthetic data. Run through these to make sure that the basics are met. We expect the score to be a perfect, 100%.

Diagnostic Report

We recommend running the Diagnostic Report to run all basic checks for data format and validity on your synthetic data at once.

run_diagnostic

Use this function to run a diagnostic on the synthetic data.

from sdv.evaluation import run_diagnostic

diagnostic_report = run_diagnostic(
    real_data=real_data,
    synthetic_data=synthetic_data,
    metadata=metadata)
Generating report ...

(1/3) Evaluating Data Validity: |██████████| 15/15 [00:00<00:00, 603.69it/s]|
Data Validity Score: 100.0%

(2/3) Evaluating Data Structure: |██████████| 2/2 [00:00<00:00, 151.49it/s]|
Data Structure Score: 100.0%

(3/3) Evaluating Relationship Validity: |██████████| 1/1 [00:00<00:00, 68.51it/s]|
Relationship Validity Score: 100.0%

Overall Score (Average): 100.0%

Parameters:

  • (required) real_data: The original training data. For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data.

  • (required) synthetic_data: Your synthetic data. For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data.

  • (required) metadata: A Metadata object with your metadata

  • verbose: A boolean describing whether or not to print the report progress and results. Defaults to True. Set this to False to run the report silently.

Returns: An SDMetrics DiagnosticReport object generated with your real and synthetic data

Interpreting the Score

The basic diagnostic checks are summarized in the table below.

Property
Description

Data Validity

Basic validity checks for each of the columns:

  1. Primary keys must always be unique and non-null

  2. Continuous values in the synthetic data must adhere to the min/max range in the real data

  3. Discrete values in the synthetic data must adhere to the same categories as the real data.

  4. ID columns must adhere to the provided Regex format.

  5. Datetime columns must adhere to the provided datetime format.

Structure

Checks to ensure the real and synthetic data have the same column names

Relationship Validity

For multi-table data only. Basic validity checks for each relationship between a parent table and a child table:

  1. Each primary key in the parent table must have an appropriate number of children (i.e. cardinality) based on the min/max of the real data.

  2. Each foreign key in the child table must reference a primary key that exists in the parent (i.e. referential integrity).

get_details

This function returns details about the report's properties. Use it to pinpoint the exact columns or tables that are causing issues.

Parameters:

  • (required) property_name: A string with the name of the property. One of: 'Data Validity', 'Structure', or 'Relationship Validity'

  • table_name: For multi table data, a string with the name of the table. If provided, you'll receive filtered results for the table.

Returns A pandas.DataFrame object with the detailed scores

Utilities

Use this function to manually check for referential integrity across a few randomly-selected values from the synthetic data. This is useful for demo purposes.

To run a full referential integrity check for all values across all relationships, we recommend running the Diagnostic Report instead.

Parameters:

  • (required) metadata: The metadata object that corresponds to your data schema.

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

  • (required) table_name: A string containing the table name that has the foreign key to check

  • (required) foreign_key_name: A string with the column of the foreign key to check. For composite keys, provide a tuple of strings.

  • num_rows: An int containing the number of columns to check; defaults to 10.

Returns: None. The function chooses a few foreign key values random from the synthetic data and checks to make sure the references are found in the parent table. It prints out the result for each column.

Last updated