Danger You are looking at the documentation for an older version of the SDV! We are no longer supporting or maintaining this version of the software Click here to go to the new docs pages.
Danger
You are looking at the documentation for an older version of the SDV! We are no longer supporting or maintaining this version of the software
Click here to go to the new docs pages.
sdv.tabular.ctgan.
CTGAN
Model wrapping CTGAN model.
field_names (list[str]) – List of names of the fields that need to be modeled and included in the generated output data. Any additional fields found in the data will be ignored and will not be included in the generated output. If None, all the fields found in the data are used.
None
field_types (dict[str, dict]) – Dictinary specifying the data types and subtypes of the fields that will be modeled. Field types and subtypes combinations must be compatible with the SDV Metadata Schema.
field_transformers (dict[str, str]) –
Dictinary specifying which transformers to use for each field. Available transformers are:
FloatFormatter: Uses a FloatFormatter for numerical data. FrequencyEncoder: Uses a FrequencyEncoder without gaussian noise. FrequencyEncoder_noised: Uses a FrequencyEncoder adding gaussian noise. OneHotEncoder: Uses a OneHotEncoder. LabelEncoder: Uses a LabelEncoder without gaussian nose. LabelEncoder_noised: Uses a LabelEncoder adding gaussian noise. BinaryEncoder: Uses a BinaryEncoder. UnixTimestampEncoder: Uses a UnixTimestampEncoder.
FloatFormatter: Uses a FloatFormatter for numerical data.
FloatFormatter
FrequencyEncoder: Uses a FrequencyEncoder without gaussian noise.
FrequencyEncoder
FrequencyEncoder_noised: Uses a FrequencyEncoder adding gaussian noise.
FrequencyEncoder_noised
OneHotEncoder: Uses a OneHotEncoder.
OneHotEncoder
LabelEncoder: Uses a LabelEncoder without gaussian nose.
LabelEncoder
LabelEncoder_noised: Uses a LabelEncoder adding gaussian noise.
LabelEncoder_noised
BinaryEncoder: Uses a BinaryEncoder.
BinaryEncoder
UnixTimestampEncoder: Uses a UnixTimestampEncoder.
UnixTimestampEncoder
anonymize_fields (dict[str, str]) – Dict specifying which fields to anonymize and what faker category they belong to.
primary_key (str) – Name of the field which is the primary key of the table.
constraints (list[Constraint, dict]) – List of Constraint objects or dicts.
table_metadata (dict or metadata.Table) – Table metadata instance or dict representation. If given alongside any other metadata-related arguments, an exception will be raised. If not given at all, it will be built using the other arguments or learned from the data.
embedding_dim (int) – Size of the random sample passed to the Generator. Defaults to 128.
generator_dim (tuple or list of ints) – Size of the output samples for each one of the Residuals. A Residual Layer will be created for each one of the values provided. Defaults to (256, 256).
discriminator_dim (tuple or list of ints) – Size of the output samples for each one of the Discriminator Layers. A Linear Layer will be created for each one of the values provided. Defaults to (256, 256).
generator_lr (float) – Learning rate for the generator. Defaults to 2e-4.
generator_decay (float) – Generator weight decay for the Adam Optimizer. Defaults to 1e-6.
discriminator_lr (float) – Learning rate for the discriminator. Defaults to 2e-4.
discriminator_decay (float) – Discriminator weight decay for the Adam Optimizer. Defaults to 1e-6.
batch_size (int) – Number of data samples to process in each step.
discriminator_steps (int) – Number of discriminator updates to do for each generator update. From the WGAN paper: https://arxiv.org/abs/1701.07875. WGAN paper default is 5. Default used is 1 to match original CTGAN implementation.
log_frequency (boolean) – Whether to use log frequency of categorical levels in conditional sampling. Defaults to True.
True
verbose (boolean) – Whether to have print statements for progress results. Defaults to False.
False
epochs (int) – Number of training epochs. Defaults to 300.
pac (int) – Number of samples to group together when applying the discriminator. Defaults to 10.
cuda (bool or str) – If True, use CUDA. If a str, use the indicated device. If False, do not use cuda at all.
str
learn_rounding_scheme (bool) – Define rounding scheme for FloatFormatter. If True, the data returned by reverse_transform will be rounded to that place. Defaults to True.
reverse_transform
enforce_min_max_values (bool) – Specify whether or not to clip the data returned by reverse_transform of the numerical transformer, FloatFormatter, to the min and max values seen during fit. Defaults to True.
fit
__init__
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__([field_names, field_types, …])
Initialize self.
fit(data)
Fit this model to the data.
get_metadata()
get_metadata
Get metadata about the table.
get_parameters()
get_parameters
Get the parameters learned from the data.
load(path)
load
Load a TabularModel instance from a given path.
sample(num_rows[, randomize_samples, …])
sample
Sample rows from this table.
sample_conditions(conditions[, …])
sample_conditions
Sample rows from this table with the given conditions.
sample_remaining_columns(known_columns[, …])
sample_remaining_columns
save(path)
save
Save this model instance to the given path using cloudpickle.
set_parameters(parameters)
set_parameters
Regenerate a previously learned model from its parameters.