@@ -69,6 +69,10 @@ def __init__(self, dataset_id=None, name=None, version=None, description=None,
6969 self .ignore_attributes = [ignore_attribute ]
7070 elif isinstance (ignore_attribute , list ):
7171 self .ignore_attributes = ignore_attribute
72+ elif ignore_attribute is None :
73+ pass
74+ else :
75+ raise ValueError ('wrong data type for ignore_attribute. Should be list. ' )
7276 self .version_label = version_label
7377 self .citation = citation
7478 self .tag = tag
@@ -88,7 +92,8 @@ def __init__(self, dataset_id=None, name=None, version=None, description=None,
8892 xmlfeature ['oml:data_type' ],
8993 None , #todo add nominal values (currently not in database)
9094 int (xmlfeature ['oml:number_of_missing_values' ]))
91- assert idx == feature .index , "Data features not provided in right order"
95+ if idx != feature .index :
96+ raise ValueError ('Data features not provided in right order' )
9297 self .features [feature .index ] = feature
9398
9499
@@ -313,7 +318,21 @@ def retrieve_class_labels(self, target_name='class'):
313318 return None
314319
315320
316- def get_features_by_type (self , data_type , exclude = None , exclude_ignore_attributes = True , exclude_row_id_attribute = True ):
321+ def get_features_by_type (self , data_type , exclude = None ,
322+ exclude_ignore_attributes = True , exclude_row_id_attribute = True ):
323+ '''
324+ Returns indices of features of a given type, e.g., all nominal features.
325+ Can use additional parameters to exclude various features by index or ontology.
326+
327+ :param data_type: The data type to return (e.g., nominal, numeric, date, string)
328+ :param exclude: Indices to exclude (and adapt the return values as if these indices
329+ are not present)
330+ :param exclude_ignore_attributes: Whether to exclude the defined ignore attributes
331+ (and adapt the return values as if these indices are not present)
332+ :param exclude_row_id_attribute:Whether to exclude the defined row id attributes
333+ (and adapt the return values as if these indices are not present)
334+ :return: a list of indices that have the specified data type
335+ '''
317336 assert data_type in OpenMLDataFeature .LEGAL_DATA_TYPES , "Illegal feature type requested"
318337 if self .ignore_attributes is not None :
319338 assert type (self .ignore_attributes ) is list , "ignore_attributes should be a list"
0 commit comments