Skip to content

Commit 4559071

Browse files
authored
FIX: explicit conversion to original sparse format in SMOTENC (#539)
2 parents 7a2a494 + bc3a673 commit 4559071

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/whats_new/v0.5.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ Bug
3131
was moved before the activation function and the bias was removed from the
3232
dense layer.
3333
:issue:`531` by :user:`Guillaume Lemaitre <glemaitre>`.
34+
35+
- Fix bug which converting to COO format sparse when stacking the matrices in
36+
:class:`imblearn.over_sampling.SMOTENC`. This bug was only old scipy version.
37+
:issue:`539` by :user:`Guillaume Lemaitre <glemaitre>`.

imblearn/over_sampling/_smote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@ def _sample(self, X, y):
815815

816816
if sparse.issparse(X_new):
817817
X_resampled = sparse.vstack([X_resampled, X_new])
818+
sparse_func = 'tocsc' if X.format == 'csc' else 'tocsr'
819+
X_resampled = getattr(X_resampled, sparse_func)()
818820
else:
819821
X_resampled = np.vstack((X_resampled, X_new))
820822
y_resampled = np.hstack((y_resampled, y_new))

0 commit comments

Comments
 (0)