@@ -419,7 +419,7 @@ def create_dataset(name, description, creator, contributor,
419419 licence , attributes , data ,
420420 default_target_attribute ,
421421 ignore_attribute , citation ,
422- row_id_attribute = None , format = None ,
422+ row_id_attribute = None ,
423423 original_data_url = None , paper_url = None ,
424424 update_comment = None , version_label = None ):
425425 """Create a dataset.
@@ -473,11 +473,6 @@ def create_dataset(name, description, creator, contributor,
473473 be discarded.
474474 .. versionadded: 0.8
475475 Inference of ``row_id_attribute`` from a dataframe.
476- format : str, optional
477- Format of the dataset which can be either 'arff' or 'sparse_arff'.
478- By default, the format is automatically inferred.
479- .. deprecated: 0.8
480- ``format`` is deprecated in 0.8 and will be removed in 0.10.
481476 original_data_url : str, optional
482477 For derived data, the url to the original dataset.
483478 paper_url : str, optional
@@ -536,34 +531,29 @@ def create_dataset(name, description, creator, contributor,
536531 else :
537532 data = data .values
538533
539- if format is not None :
540- warn ("The format parameter will be deprecated in the future,"
541- " the method will determine the format of the ARFF "
542- "based on the given data." , DeprecationWarning )
543- d_format = format
544-
545- # Determine ARFF format from the dataset
546- else :
547- if isinstance (data , (list , np .ndarray )):
548- if isinstance (data [0 ], (list , np .ndarray )):
549- d_format = 'arff'
550- elif isinstance (data [0 ], dict ):
551- d_format = 'sparse_arff'
552- else :
553- raise ValueError (
554- 'When giving a list or a numpy.ndarray, '
555- 'they should contain a list/ numpy.ndarray '
556- 'for dense data or a dictionary for sparse '
557- 'data. Got {!r} instead.'
558- .format (data [0 ])
559- )
560- elif isinstance (data , coo_matrix ):
561- d_format = 'sparse_arff'
534+ if isinstance (data , (list , np .ndarray )):
535+ if isinstance (data [0 ], (list , np .ndarray )):
536+ data_format = 'arff'
537+ elif isinstance (data [0 ], dict ):
538+ data_format = 'sparse_arff'
562539 else :
563540 raise ValueError (
564- 'Invalid data type. The data type can be a list, '
565- 'a numpy ndarray or a scipy.sparse.coo_matrix'
541+ 'When giving a list or a numpy.ndarray, '
542+ 'they should contain a list/ numpy.ndarray '
543+ 'for dense data or a dictionary for sparse '
544+ 'data. Got {!r} instead.'
545+ .format (data [0 ])
566546 )
547+ elif isinstance (data , coo_matrix ):
548+ data_format = 'sparse_arff'
549+ else :
550+ raise ValueError (
551+ 'When giving a list or a numpy.ndarray, '
552+ 'they should contain a list/ numpy.ndarray '
553+ 'for dense data or a dictionary for sparse '
554+ 'data. Got {!r} instead.'
555+ .format (data [0 ])
556+ )
567557
568558 arff_object = {
569559 'relation' : name ,
@@ -577,10 +567,11 @@ def create_dataset(name, description, creator, contributor,
577567 try :
578568 # check if ARFF is valid
579569 decoder = arff .ArffDecoder ()
570+ return_type = arff .COO if data_format == 'sparse_arff' else arff .DENSE
580571 decoder .decode (
581572 arff_dataset ,
582573 encode_nominal = True ,
583- return_type = arff . COO if d_format == 'sparse_arff' else arff . DENSE
574+ return_type = return_type
584575 )
585576 except arff .ArffException :
586577 raise ValueError ("The arguments you have provided \
@@ -589,7 +580,7 @@ def create_dataset(name, description, creator, contributor,
589580 return OpenMLDataset (
590581 name ,
591582 description ,
592- data_format = d_format ,
583+ data_format = data_format ,
593584 creator = creator ,
594585 contributor = contributor ,
595586 collection_date = collection_date ,
0 commit comments