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

Anonymizing PII Values

An important aspect of privacy is to ensure that the synthetic data isn't repeating original PII values from the real data. This also includes combinations of other types of columns that can, together, identify original entities in the real data. Use the the functions listed in this page to verify that PII values are newly created in synthetic data.

get_pii_overlap

Use this function when you have a PII column in the real data and you'd like to ensure that the synthetic data does not repeat those PII values.

from sdv.evaluation.utils import get_pii_overlap

overlap_amt = get_pii_overlap(
    real_data=real_data,
    synthetic_data=synthetic_data,
    table_name=table_name,
    pii_column_name='ssn',
    verbose=True
)
Number of common data points: 0 (0.0%)
✅ The synthetic data does not contain any PII values from the real data

Parameters:

  • (required) real_data: A dictionary mapping a table name to a pandas.DataFrame containing real data

  • (required) synthetic_data: A dictionary mapping a table name to a pandas.DataFrame containing synthetic data

  • (required) table_name: The name of the table that contains the PII column to check

  • (required) pii_column_name: The name of the column that contains PII values to check

  • verbose: Whether to print out the interpretation of the result

    • (default) True: Print out the interpretation of the result

    • False: Do not print anything out. Only return the final result.

Returns: The # of PII data points in the synthetic data that have the exact same value as the real data.

get_combination_overlap

Use this function when a few columns together could be used to identify an entity from the real data — for example a person's zipcode, gender, and date of birth. In this case, you'd like to ensure that the synthetic data doesn't repeat the exact combinations that occur in the real data.

Parameters:

  • (required) real_data: A dictionary mapping a table name to a pandas.DataFrame containing real data

  • (required) synthetic_data: A dictionary mapping a table name to a pandas.DataFrame containing synthetic dat

  • (required) table_name: The name of the table that contains the columns to check

  • (required) column_names: A list of strings represent the column names to check. Combinations of these columns will be checked.

  • verbose: Whether to print out the interpretation of the results

Returns: The # of rows in the synthetic data that contain the exact same combination of values as the real data (for the given columns).

Interpreting the Overlap

In many cases, you'll see that there are 0 common PII values or combinations which indicates that the values are anonymized in the synthetic data. But having a few overlapping values is not necessarily a bad thing in fact, it can indicate that good privacy practices if you have large amounts of synthetic data.

This happens when there are relatively few values possible, and/or when you have sampled a very large amount of synthetic data. In this case, it's possible to have an overlap due to random chance. For example, a US social security number is a 9-digit number such as 123-45-6789; if you generate billions of synthetic data points, the synthetic data may end up up containing a real value due to random chance. This is actually a good thing: If the synthetic data purposefully avoided creating any of the real values, then we might be able to deduce the real values by looking up what does not appear in the synthetic data. This would violate privacy.

For this reason, if the overlap is relatively small (<2% of synthetic data points), then the functions will interpret this as a warning so that you're aware of it, but it's not necessarily something to worry about. Use your judgement when interpreting this result and get in touch with us if you need help.

Last updated