Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Handling sparse targets when dataset as arrays
  • Loading branch information
Neeratyoy committed Apr 21, 2021
commit 244d9bb66aa25acfe4c31f9e292ffe9896bfc1f8
3 changes: 3 additions & 0 deletions openml/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ def get_data(
attribute_names = [att for att, k in zip(attribute_names, targets) if not k]

x = self._convert_array_format(x, dataset_format, attribute_names)
if dataset_format == "array" and scipy.sparse.issparse(y):
# scikit-learn requires dense representation of targets
y = np.asarray(y.todense()).astype(target_dtype)
if not scipy.sparse.issparse(y):
y = y.squeeze()
y = self._convert_array_format(y, dataset_format, target_names)
Expand Down