Skip to content

get_columns_from_metadata() does not work anymore! #709

Closed
@wilcovanvorstenbosch

Description

@wilcovanvorstenbosch

The function does not work, probably because of the new MetaData class??

def get_columns_from_metadata(metadata):
    """Get the column info from a metadata dict.

    Args:
        metadata (dict):
            The metadata dict.

    Returns:
        dict:
            The columns metadata.
    """
    return metadata.get('columns', {})

I found out when trying out the LogisticDetection.compute() function, which gave the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 3
      1 from sdmetrics.single_table import LogisticDetection, SVCDetection
----> 3 LogisticDetection.compute(
      4     real_data=real,
      5     synthetic_data=synth,
      6     metadata=metadata
      7 )

File ~\AppData\Roaming\Python\Python312\site-packages\sdmetrics\single_table\detection\base.py:94, in DetectionMetric.compute(cls, real_data, synthetic_data, metadata)
     72 @classmethod
     73 def compute(cls, real_data, synthetic_data, metadata=None):
     74     """Compute this metric.
     75 
     76     This builds a Machine Learning Classifier that learns to tell the synthetic
   (...)
     92             One minus the ROC AUC Cross Validation Score obtained by the classifier.
     93     """
---> 94     real_data, synthetic_data, metadata = cls._validate_inputs(
     95         real_data, synthetic_data, metadata
     96     )
     98     transformed_real_data, transformed_synthetic_data = cls._drop_non_compute_columns(
     99         real_data, synthetic_data, metadata
    100     )
...
--> 117         raise ValueError(f'Column {column} not found in metadata')
    119 for field, field_meta in fields.items():
    120     field_type = get_type_from_column_meta(field_meta)

ValueError: Column KredietAanbieder not found in metadata

This ValueError is raised because metadata.get('columns') returns None, when using a MetaData object as an argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingresolution:WAIThe software is working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions