Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/progress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog

0.11.0
~~~~~~
* ADD #929: Fix data edit API
Comment thread
PGijsbers marked this conversation as resolved.
Outdated
* ADD #929: Add data edit API
* FIX #873: Fixes an issue which resulted in incorrect URLs when printing OpenML objects after
switching the server.
Expand Down
14 changes: 11 additions & 3 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,18 @@ def edit_dataset(
]
):
logger.warning("Creating a new version of dataset, cannot edit existing version")

# Get old dataset and features
dataset = get_dataset(data_id)
df, y, categorical, attribute_names = dataset.get_data(dataset_format="dataframe")
attributes_old = attributes_arff_from_df(df)

decoded_arff = dataset._get_arff(format="arff")
data_old = decoded_arff["data"]
# Sparse data needs to be provided in a different format from dense data
if dataset.format == "sparse_arff":
df, y, categorical, attribute_names = dataset.get_data(dataset_format="array")
data_old = coo_matrix(df)
else:
data_old = df
data_new = data if data is not None else data_old
dataset_new = create_dataset(
name=dataset.name,
Expand All @@ -904,7 +912,7 @@ def edit_dataset(
collection_date=collection_date or dataset.collection_date,
language=language or dataset.language,
licence=dataset.licence,
attributes=attributes or decoded_arff["attributes"],
attributes=attributes or attributes_old,
data=data_new,
default_target_attribute=default_target_attribute or dataset.default_target_attribute,
ignore_attribute=ignore_attribute or dataset.ignore_attribute,
Expand Down