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

GaussianCopula get_learned_distributions crashes if nothing was learned #2297

Open
npatki opened this issue Nov 15, 2024 · 0 comments
Open
Labels
bug Something isn't working data:single-table Related to tabular datasets

Comments

@npatki
Copy link
Contributor

npatki commented Nov 15, 2024

Environment Details

  • SDV version: 1.17.2.dev0 (but also reproducible on latest SDV version)

Error Description

In some instances, I may have a dataset with columns where nothing gets modeled. For eg, I may just have ID columns, or I may have PII columns that don't get modeled (they are using AnonymizedFaker).

In these instances, fitting and sampling work just fine. But get_learned_distributions causes a crash.

Steps to reproduce

import pandas as pd
from sdv.metadata import Metadata
from sdv.single_table import  GaussianCopulaSynthesizer
import numpy as np

metadata = Metadata().load_from_dict({
    'tables': {
        'table1': {
            'columns': {
                'col_1': {'sdtype': 'id'},
                'col_2': { 'sdtype': 'credit_card_number'}
            },
        }
    }
})
data = pd.DataFrame({
    'col_1': range(100),
    'col_2': range(100)
})

synthesizer = GaussianCopulaSynthesizer(metadata, default_distribution='beta')
synthesizer.fit(data)
synthesizer.get_learned_distributions()
[/usr/local/lib/python3.10/dist-packages/sdv/single_table/copulas.py](https://localhost:8080/#) in get_learned_distributions(self)
    219             )
    220 
--> 221         parameters = self._model.to_dict()
    222         columns = parameters['columns']
    223         univariates = deepcopy(parameters['univariates'])

AttributeError: 'NoneType' object has no attribute 'to_dict'

Expected Behavior

If nothing was learned, then get_learned_distributions should just return an empty dict.

synthesizer.get_learned_distributions()
{}
@npatki npatki added bug Something isn't working data:single-table Related to tabular datasets labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data:single-table Related to tabular datasets
Projects
None yet
Development

No branches or pull requests

1 participant