Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTGANSynthesizer is assigning LabelEncoder to boolean columns (instead of None) #1530

Closed
npatki opened this issue Aug 3, 2023 · 0 comments · Fixed by #1547
Closed

CTGANSynthesizer is assigning LabelEncoder to boolean columns (instead of None) #1530

npatki opened this issue Aug 3, 2023 · 0 comments · Fixed by #1547
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Aug 3, 2023

Environment Details

  • SDV version: 1.2.1

Error Description

If I am using the CTGANsynthesizer, then there is no need to apply any transformers to discrete data. Currently, the data preprocessor assigns None (no transformer) to categorical columns but it assigns LabelEncoder(add_noise=True) to boolean columns. This makes it inefficient to model boolean columns, as the CTGANSynthesizer then one hot encodes all those values (see #1450 as to why)

Workaround

Just update the sdtype from boolean to categorical and then the preprocessing will work as intended.

Steps to reproduce

import pandas as pd
from sdv.metadata import SingleTableMetadata
from sdv.single_table import CTGANSynthesizer

data = pd.DataFrame(data={
    'age': [56, 61, 36, 52, 42],
    'biomarker': [0.863, 0.885, 0.285, 0.293, 0.192],
    'therapy': [True, False, True, False, True],
    'alcohol': ['medium', 'medium', 'low', 'high', 'low'],
})

metadata = SingleTableMetadata.load_from_dict({
    'columns': {
        'age': { 'sdtype': 'numerical' },
        'biomarker': { 'sdtype': 'numerical' },
        'therapy': { 'sdtype': 'boolean' },
        'alcohol': { 'sdtype': 'categorical' }
    }
})

synth = CTGANSynthesizer(metadata)
synth.auto_assign_transformers(data)
synth.get_transformers()

Output:

{'age': FloatFormatter(learn_rounding_scheme=True, enforce_min_max_values=True),
 'biomarker': FloatFormatter(learn_rounding_scheme=True, enforce_min_max_values=True),
 'therapy': LabelEncoder(add_noise=True),
 'alcohol': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants