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

Dependent GreaterThan constraints doesn't work #371

Closed
fealho opened this issue Mar 31, 2021 · 2 comments
Closed

Dependent GreaterThan constraints doesn't work #371

fealho opened this issue Mar 31, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@fealho
Copy link
Member

fealho commented Mar 31, 2021

As mentioned in #366, two dependent GreaterThan constraints currently doesn't work. Even though this is not exactly supported, it should still work, indicating a possible bug in the code.

Below is an example where the synthetic data for low should be smaller than for n, and n smaller than high, but it doesn`t work:

import pandas as pd
from sdv.tabular import CTGAN
from sdv.constraints import GreaterThan

data = pd.DataFrame({
    'id': str(i) for i in range(300),
    'low': 1.0, 2.0, 3.0100,
    'n': 1.0, 2.0, 3.0100,
    'high': 1.0, 2.0, 3.0*100
})

low_constraint = GreaterThan(low='low',high='n',handling_strategy='transform')
high_constraint = GreaterThan(low='n',high='high',handling_strategy='transform')
constraints = high_constraint, low_constraint

model = CTGAN(epochs=50, primary_key='id', constraints=constraints)
model.fit(data)
model.sample(100)
@fealho fealho added bug Something isn't working pending review and removed pending review labels Mar 31, 2021
@fealho
Copy link
Member Author

fealho commented Mar 31, 2021

I think the reason for this error is here: https://github.com/sdv-dev/SDV/blob/master/sdv/metadata/table.py#L554.

Instead, since we are trying to revert the transforms, we should iterate over the constraints in the reverse order.

for constraint in reversed(self._constraints):

@sync-by-unito sync-by-unito bot changed the title Dependent GreaterThan constraints doesn't work SDV - #371 Dependent GreaterThan constraints doesn't work Apr 13, 2021
@sync-by-unito sync-by-unito bot changed the title SDV - #371 Dependent GreaterThan constraints doesn't work Dependent GreaterThan constraints doesn't work Apr 13, 2021
@csala
Copy link
Contributor

csala commented Aug 25, 2021

This was covered by the Between constraint introduced in #367

@csala csala closed this as completed Aug 25, 2021
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

No branches or pull requests

2 participants