Skip to content

How to know and skip if dataset having string features? "PyOpenMLError: Dataset 376 not compatible, PyOpenML cannot handle string features" #497

Description

@vchouksey

Description

PyOpenMLError: Dataset 376 not compatible, PyOpenML cannot handle string features

Steps/Code to Reproduce

 1 def new_df(ds):
2 dataset = oml.datasets.get_dataset(ds)
3 X, y_true, categorical = dataset.get_data(target=dataset.default_target_attribute, return_categorical_indicator=True)
4 X, y, attribute_names = dataset.get_data(target=dataset.default_target_attribute, return_attribute_names=True)
5 halloffame = pd.DataFrame(X, columns=attribute_names)

/usr/local/anaconda/lib/python3.6/site-packages/openml-0.7.0-py3.6.egg/openml/datasets/dataset.py in get_data(self, target, include_row_id, include_ignore_attributes, return_categorical_indicator, return_attribute_names)
227 raise PyOpenMLError(
228 'Dataset %d not compatible, PyOpenML cannot handle string '
229 'features' % self.dataset_id
230 )
231

PyOpenMLError: Dataset 376 not compatible, PyOpenML cannot handle string features

Expected Results

Skip these type of errors or precheck or fix?

Actual Results

Already doing one-hot encoding see below

 dataset = oml.datasets.get_dataset(ds)
X, y_true, categorical = dataset.get_data(target=dataset.default_target_attribute, return_categorical_indicator=True)
X, y, attribute_names = dataset.get_data(target=dataset.default_target_attribute, return_attribute_names=True)
halloffame = pd.DataFrame(X, columns=attribute_names)
if halloffame.isnull().values.any() == True:
imp = preprocessing.Imputer(strategy='median')
X = imp.fit_transform(X)
enc = preprocessing.OneHotEncoder(categorical_features=categorical) X = enc.fit_transform(X)

Versions

Linux-3.13.0-147-generic-x86_64-with-debian-jessie-sid
Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.13.3.10
SciPy 1.0.0.0
Scikit-Learn 0.19.0
OpenML 0.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions