Evaluation
As a final step to your synthetic data project, you can evaluate and visualize the synthetic data against the real data.
Compare the real and synthetic data to determine whether the statistical and mathematical properties are similar.
Use this function to evaluate the quality of your synthetic data in terms of column shapes, correlations and parent-child relationships.
from sdv.evaluation.multi_table import evaluate_quality
quality_report = evaluate_quality(
real_data=real_data,
synthetic_data=synthetic_data,
metadata=metadata)
Creating report: 100%|██████████| 4/4 [00:00<00:00, 7.09it/s]
Overall Quality Score: 82.84%
Properties:
Column Shapes: 82.78%
Column Pair Trends: 82.9%
Table Relationships: 77%
Parameters
- (required)
real_data
: A dictionary mapping each table name to a pandas DataFrame object with the real data - (required)
synthetic_data
: A dictionary mapping each table name to a pandas DataFrame object with the synthetic data verbose
: A boolean that indicates whether to print the progress of running the diagnostic. Defaults toTrue
.
The quality report contains a summary of the overall quality as well as detailed breakdowns to uncover new insights. You can interact with the object to learn more.
>>> quality_report.get_score()
0.783449101193
>>> quality_report.get_properties()
Property Score
Column Shapes 0.8278
Column Pair Trends 0.8290
Parent Child Relationships 0.77110
>>> quality_report.get_details(property_name='Column Shapes', table_name='guests')
Table Column Metric Quality Score
guests amenities_fee KSComplement 0.921127
guests checkin_date KSComplement 0.926000
...
Use this function to receive some diagnostic results about your synthetic data. Check to see if the synthetic rows are pure copies of the real data, if the synthetic data covers the full range of values and if the synthetic data adheres to the original ranges.
sdv.evaluation.multi_table import run_diagnostic
diagnostic_report = run_diangnostic(
real_data=real_data,
synthetic_data=synthetic_data,
metadata=metadata)
Creating report: 100%|████████████████| 200/200 [01:21<00:03, 2.37it/s]
Diagnostic Results
SUCCESS
✓ Over 90% of the synthetic rows are not copies of the real data
✓ The synthetic data covers over 90% of the numerical ranges present in the
real data
WARNING
! The synthetic data is missing more than 10% of the categories present in
the real data
DANGER
x More than 50% the synthetic data does not follow the min/max boundaries
set by the real data
Parameters
- (required)
synthetic_data
: A dictionary mapping each table name to a pandas DataFrame object with the synthetic data - (required)
real_data
: A dictionary mapping each table name to a pandas DataFrame object with the real data verbose
: A boolean that indicates whether to print the progress of running the diagnostic. Defaults toTrue
.
The diagnostic report contains a summary as well as detailed breakdowns to uncover new insights. You can interact with the object to learn more.
>>> diagnostic_report.get_results()
{
'SUCCESS': [
'Over 90% of the synthetic rows are not copies of the real data',
'The synthetic data covers over 90% of the numerical ranges present in the real data'
],
...
}
>>> diagnostic_report.get_properties()
{
'Synthesis': 1.0,
'Coverage': 0.85,
'Boundaries': 0.90
}
>>> diagnostic_report.get_details(property_name='Coverage', table_name='guests')
Table Column Metric Score
guests amenities_fee RangeCoverage 1.00000
guests checkin_date RangeCoverage 1.00000
...
Visualize the shapes of your columns in 1D and 2D.
Use this function to visualize a real column against the same synthetic column. You can plot any column of type:
boolean
, categorical
, datetime
or numerical
. from sdv.evaluation.single_table import get_column_plot
fig = get_column_plot(
real_data=real_data,
synthetic_data=synthetic_data,
table_name='guests',
column_name='amenities_fee',
metadata=metadata
)
fig.show()

Parameters
- (required)
table_name
: The name of the table - (required)
column_name
: The name of the column in the table you want to plot
Use
fig.show()
to see the plot in an iPython notebook. The plot is interactive, allowing you to zoom, scroll and take screenshots.Use this utility to visualize the trends between a pair of columns for real and synthetic data. You can plot any 2 columns of type:
boolean
, categorical
, datetime
or numerical
. The columns do not have to the be the same type.from sdv.evaluation.single_table import get_column_pair_plot
fig = get_column_pair_plot(
real_data=real_data,
synthetic_data=synthetic_data,
table_name='guests',
column_names=['room_rate', 'room_type'],
metadata=metadata)
fig.show()
Parameters
- (required)
table_name
: The name of the table - (required)
column_names
: A list with the names of the 2 columns you want to plot. Both columns must be in the table you specified.
Use
fig.show()
to see the plot in an iPython notebook. The plot is interactive, allowing you to zoom, scroll and take screenshots.This library includes many more metrics (some experimental) that you can apply based on your goals. All you need is your real data, synthetic data and metadata to get started.
Last modified 1mo ago