pe.callback.tabular.compute_tvd module

class pe.callback.tabular.compute_tvd.ComputeTVD(priv_data, degree, num_bins=20, filter_criterion=None)[source]

Bases: Callback

The callback that computes the Total Variation Distance (TVD) between the private and synthetic data.

__call__(syn_data)[source]

This function is called after each PE iteration that computes the TVD between the private and synthetic data.

Parameters:

syn_data (pe.data.Data) – The synthetic data

Returns:

The TVD between the private and synthetic data

Return type:

list[pe.metric_item.FloatMetricItem]

__init__(priv_data, degree, num_bins=20, filter_criterion=None)[source]

Constructor.

Parameters:
  • priv_data (pe.data.Data) – The private data

  • degree (int) – The degree of the TVD (e.g., 2 for 2-way TVD)

  • num_bins (int, optional) – The number of bins to compute the TVD, defaults to 20

  • filter_criterion (dict, optional) – Only computes the metric based on samples satisfying the criterion. None means no filtering. Defaults to None

_compute_tvd(syn_features_df, priv_features_df)[source]

Compute the TVD between the synthetic and private features.

Parameters:
  • syn_features_df (pandas.DataFrame) – The synthetic features DataFrame

  • priv_features_df (pandas.DataFrame) – The private features DataFrame

Returns:

The TVD

Return type:

float

_get_features_df(data)[source]

Get the features DataFrame from the data.

Parameters:

data (pe.data.Data) – The data

Returns:

The features DataFrame

Return type:

pandas.DataFrame