@@ -806,8 +806,6 @@ def edit_dataset(
806806 contributor = None ,
807807 collection_date = None ,
808808 language = None ,
809- attributes = None ,
810- data = None ,
811809 default_target_attribute = None ,
812810 ignore_attribute = None ,
813811 citation = None ,
@@ -839,17 +837,6 @@ def edit_dataset(
839837 language : str
840838 Language in which the data is represented.
841839 Starts with 1 upper case letter, rest lower case, e.g. 'English'.
842- attributes : list, dict, or 'auto'
843- A list of tuples. Each tuple consists of the attribute name and type.
844- If passing a pandas DataFrame, the attributes can be automatically
845- inferred by passing ``'auto'``. Specific attributes can be manually
846- specified by a passing a dictionary where the key is the name of the
847- attribute and the value is the data type of the attribute.
848- data : ndarray, list, dataframe, coo_matrix, shape (n_samples, n_features)
849- An array that contains both the attributes and the targets. When
850- providing a dataframe, the attribute names and type can be inferred by
851- passing ``attributes='auto'``.
852- The target feature is indicated as meta-data of the dataset.
853840 default_target_attribute : str
854841 The default target attribute, if it exists.
855842 Can have multiple values, comma separated.
@@ -879,54 +866,6 @@ def edit_dataset(
879866 if not isinstance (data_id , int ):
880867 raise TypeError ("`data_id` must be of type `int`, not {}." .format (type (data_id )))
881868
882- # case 1, changing these fields creates a new version of the dataset with changed field
883- if any (
884- field is not None
885- for field in [
886- data ,
887- attributes ,
888- default_target_attribute ,
889- row_id_attribute ,
890- ignore_attribute ,
891- ]
892- ):
893- logger .warning ("Creating a new version of dataset, cannot edit existing version" )
894-
895- # Get old dataset and features
896- dataset = get_dataset (data_id )
897- df , y , categorical , attribute_names = dataset .get_data (dataset_format = "dataframe" )
898- attributes_old = attributes_arff_from_df (df )
899-
900- # Sparse data needs to be provided in a different format from dense data
901- if dataset .format == "sparse_arff" :
902- df , y , categorical , attribute_names = dataset .get_data (dataset_format = "array" )
903- data_old = coo_matrix (df )
904- else :
905- data_old = df
906- data_new = data if data is not None else data_old
907- dataset_new = create_dataset (
908- name = dataset .name ,
909- description = description or dataset .description ,
910- creator = creator or dataset .creator ,
911- contributor = contributor or dataset .contributor ,
912- collection_date = collection_date or dataset .collection_date ,
913- language = language or dataset .language ,
914- licence = dataset .licence ,
915- attributes = attributes or attributes_old ,
916- data = data_new ,
917- default_target_attribute = default_target_attribute or dataset .default_target_attribute ,
918- ignore_attribute = ignore_attribute or dataset .ignore_attribute ,
919- citation = citation or dataset .citation ,
920- row_id_attribute = row_id_attribute or dataset .row_id_attribute ,
921- original_data_url = original_data_url or dataset .original_data_url ,
922- paper_url = paper_url or dataset .paper_url ,
923- update_comment = dataset .update_comment ,
924- version_label = dataset .version_label ,
925- )
926- dataset_new .publish ()
927- return dataset_new .dataset_id
928-
929- # case 2, changing any of these fields will update existing dataset
930869 # compose data edit parameters as xml
931870 form_data = {"data_id" : data_id }
932871 xml = OrderedDict () # type: 'OrderedDict[str, OrderedDict]'
@@ -937,6 +876,9 @@ def edit_dataset(
937876 xml ["oml:data_edit_parameters" ]["oml:contributor" ] = contributor
938877 xml ["oml:data_edit_parameters" ]["oml:collection_date" ] = collection_date
939878 xml ["oml:data_edit_parameters" ]["oml:language" ] = language
879+ xml ["oml:data_edit_parameters" ]["oml:default_target_attribute" ] = default_target_attribute
880+ xml ["oml:data_edit_parameters" ]["oml:row_id_attribute" ] = row_id_attribute
881+ xml ["oml:data_edit_parameters" ]["oml:ignore_attribute" ] = ignore_attribute
940882 xml ["oml:data_edit_parameters" ]["oml:citation" ] = citation
941883 xml ["oml:data_edit_parameters" ]["oml:original_data_url" ] = original_data_url
942884 xml ["oml:data_edit_parameters" ]["oml:paper_url" ] = paper_url
0 commit comments