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

Unable to turn off rounding scheme for a column (need a warning) #2266

Closed
npatki opened this issue Oct 18, 2024 · 0 comments · Fixed by #2279
Closed

Unable to turn off rounding scheme for a column (need a warning) #2266

npatki opened this issue Oct 18, 2024 · 0 comments · Fixed by #2279
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Oct 18, 2024

Environment Details

  • SDV version: 1.17.10 (latest)
  • Python version: 3.10
  • Operating System: Linux (Colab Notebook)

Error Description

I am explicitly trying to turn off rounding for a column, but if I set up FloatFormatter with learn_rounding_scheme=False, I see that this doesn't have any effect.

Steps to reproduce

from sdv.datasets.demo import download_demo
from sdv.single_table import GaussianCopulaSynthesizer
from rdt.transformers.numerical import FloatFormatter

data, metadata = download_demo(
    modality='single_table',
    dataset_name='fake_hotel_guests'
)

synthesizer = GaussianCopulaSynthesizer(metadata)
synthesizer.auto_assign_transformers(data)

synthesizer.update_transformers({
    'amenities_fee': FloatFormatter(learn_rounding_scheme=False) # I'm trying to turn off rounding for this column
})

synthesizer.fit(data)
synthesizer.sample(5)
image

Expected Results

The code itself is actually working as intended -- because the rounding is being enforced at a synthesizer level, it's not possible to override it by just updating a transformer. In this case, I expect a warning should be thrown after update_transformers.

Warning: Unable to turn off rounding scheme for column 'amenities_fee', because the overall synthesizer is
enforcing rounding. We recommend setting the synthesizer's 'enforce_rounding' parameter to False.

Note that this warning should only appear if:

  • The synthesizer's enforce_rounding is set to True (this is also the default) AND
  • The user is providing a transformer with learn_rounding_scheme=False (they are trying to turn it off)

Additional Context

Note that the behavior is fine the other way around -- i.e. if the synthesizer's enforce_rounding=False, I am still able to turn on rounding for individual columns with using the FloatFormatter. So in this particular case, I could do this instead:

# at synthesizer level, do not enforce rounding for any of the columns
synthesizer = GaussianCopulaSynthesizer(metadata, enforce_rounding=False) 

# now, you can selectively turn rounding back ON for any columns you need
synthesizer.update_transformers({
    'room_rate': FloatFormatter(learn_rounding_scheme=True)
})

synthesizer.fit(data)
synthesizer.sample(5)
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