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

Custom Preprocessing

All synthesizers pre-process your data to prepare it for machine learning and then post-process synthetic data to convert it into the original format. This advanced feature allows you to control the transformations that are applied to each column.

Viewing the Transformations

The SDV will pre and post-process your data by using reversible data transformations for each column. The transformers are available in our RDT library.

The methods below allow you to see which transformations will be applied to each column based on the synthesizer and data you plan to use.

auto_assign_transformers

Let the synthesizer auto assign the transformations based on the data you'd like to use for modeling.

Parameters

  • (required) data: Your 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.

Output (None)

synthesizer.auto_assign_transformers(data)

get_transformers

After assigning the transformers, you can get more details about the transformers that will be used on each column.

Parameters

  • (required for multi table) table_name: A string with the table name you'd like to see the transformer for

Output A dictionary mapping each column name to an RDT transformer that will pre and post-process your data.

Modifying the Transformers

After assigning transformers, you can also modify them to customize the pre- and post-processing.

update_transformers

Use this method to reassign new transformers that you'd like to use for specific columns. You can apply any transformer in the RDT Library to your data.

Parameters

  • (required for multi table) table_name: A string representing the table name yo'd like to update the transformer for

  • (required) column_name_to_transformer: A dictionary mapping the column name to the new RDT transformer object that you'd like to use for pre and post processing.

Output (None)

* update_transformers_by_sdtype

Use this method to reassign new transformers for all columns of a specific sdtype. For example, reassign the processing for all numerical or categorical columns. You can apply any transformer in the RDT Library to your data.

*SDV Enterprise Feature. This feature is only available for licensed, enterprise users. For more information, visit our page to Compare SDV Features.

Parameters

  • (required) sdtype: A string with the name of the sdtype that you want to change the transformers for

  • (required) transformer_name: A string with the name of the transformer to use.

  • transformer_parameters: A dictionary that maps the name of the transformer parameter (string) to the parameter value. Use this if you want to override the default settings.

    • (default) None: Do not override the default settings

  • table_names: A list of strings describing the specific table names to apply the transformers to. This is applicable only for multi table data.

    • (default) None: Update the transformers for all tables

    • <list>: Only update the transformers for the given table names

Anonymizing Sensitive Data

Use the AnonymizedFaker or PsuedoAnonymizedFaker transformers for sensitive data.

Anonymization vs. Pseudo-anonymization

Pseudo-anonymization preserves a mapping between the real, sensitive values and the fake, synthetic data. Use this if you'd like to trace back the synthetic data to real values.

Anonymization is not reversible. Anyone with access to the fake, synthetic data will not be able to it back to any value of real data.

Applying the Transformations

After modifying the transformations, you can apply them to the real data in a step-wise fashion or all at once.

preprocess

Use this function to preprocess the data according to the transformations. After preprocessing, you should have numerical data that is ready for modeling.

Parameters

  • (required) data: Your 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.

Output A preprocessed version of the real data. Based on the transformations, some columns may be converted, added or removed. The output type is the same as the data input.

fit_processed_data

Use this function to perform model training on preprocessed data. Note that this step may take a while, as it requires machine learning to learn trends from your the dataset.

Parameters

  • (required) processed_data: The processed data that is ready for machine learning. This is the output of the preprocess method. 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.

Output (None). This steps trains the model using machine learning. After this step, you are ready to create synthetic data. For more details, see Sampling.

fit

Use this function to perform the preprocessing and modeling training all in one step. Internally, this uses both the preprocess and fit_processed_data functions in succession.

Parameters

  • (required) data: Your 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.

Output (None) After this step, you are ready to create synthetic data. For more details, see Sampling.

FAQ

Why am I seeing column names that are different from my original data?

If you have added constraints, then the SDV may add or delete columns to accommodate the business logic before it goes through preprocessing.

Can I remove a transformer if I don't want any processing?

In some cases, your data may already be processed such that the synthesizer does not need to perform additional transformations. You can remove transformers by assigning them to None.

Why are some of the transformers None?

Based on the data you're using, the synthesizer may determine that no transformations are necessary for machine learning. In this case, you will see that the column is not assigned to None, meaning that the data will not undergo any transformation for the machine learning model.

Last updated