Skip to content

Commit

Permalink
FIX: explicit conversion to original sparse format in SMOTENC (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Jan 28, 2019
2 parents 7a2a494 + bc3a673 commit 4559071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/whats_new/v0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ Bug
was moved before the activation function and the bias was removed from the
dense layer.
:issue:`531` by :user:`Guillaume Lemaitre <glemaitre>`.

- Fix bug which converting to COO format sparse when stacking the matrices in
:class:`imblearn.over_sampling.SMOTENC`. This bug was only old scipy version.
:issue:`539` by :user:`Guillaume Lemaitre <glemaitre>`.
2 changes: 2 additions & 0 deletions imblearn/over_sampling/_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ def _sample(self, X, y):

if sparse.issparse(X_new):
X_resampled = sparse.vstack([X_resampled, X_new])
sparse_func = 'tocsc' if X.format == 'csc' else 'tocsr'
X_resampled = getattr(X_resampled, sparse_func)()
else:
X_resampled = np.vstack((X_resampled, X_new))
y_resampled = np.hstack((y_resampled, y_new))
Expand Down

0 comments on commit 4559071

Please sign in to comment.