Skip to content

Commit 7bfda99

Browse files
committed
add sparse workaround for X too
1 parent 23d69ec commit 7bfda99

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sklbench/datasets/downloaders.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def fetch_and_correct_openml(
105105
if not isinstance(x, (csr_matrix, pd.DataFrame, np.ndarray)):
106106
raise ValueError(f'Unknown x type "{type(x)}" returned from openml')
107107

108+
# Convert sparse DataFrame to dense format
109+
if isinstance(x, pd.DataFrame):
110+
if any(pd.api.types.is_sparse(x[col]) for col in x.columns):
111+
x = x.sparse.to_dense()
112+
108113
# Convert y to numpy array if needed
109114
if isinstance(y, pd.Series):
110115
if isinstance(y.dtype, pd.CategoricalDtype):

0 commit comments

Comments
 (0)