Skip to content

Commit 0c4548a

Browse files
authored
FIX: avoid densifying sparse matrix before inverse_transform of OHE (#495)
1 parent f17107e commit 0c4548a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

doc/whats_new/v0.4.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Bug fixes
1818
target or multilabel targets. Imbalanced-learn does not support this case.
1919
By :user:`Guillaume Lemaitre <glemaitre>` in :issue:`490`.
2020

21+
- Fix a bug in :class:`imblearn.over_sampling.SMOTENC` in which an sparse
22+
matrices were densify during ``inverse_transform``.
23+
By :user:`Guillaume Lemaitre <glemaitre>` in :issue:`495`.
24+
2125
Version 0.4
2226
===========
2327

@@ -219,4 +223,4 @@ Deprecation
219223
- Deprecate ``return_indices`` in all samplers. Instead, an attribute
220224
``sample_indices_`` is created whenever the sampler is selecting a subset of
221225
the original samples.
222-
:issue:`474` by :user:`Guillaume Lemaitre <glemaitre`.
226+
:issue:`474` by :user:`Guillaume Lemaitre <glemaitre`.

imblearn/over_sampling/_smote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ def _fit_resample(self, X, y):
983983
# reverse the encoding of the categorical features
984984
X_res_cat = X_resampled[:, self.continuous_features_.size:]
985985
X_res_cat.data = np.ones_like(X_res_cat.data)
986-
X_res_cat_dec = self.ohe_.inverse_transform(X_res_cat.toarray())
986+
X_res_cat_dec = self.ohe_.inverse_transform(X_res_cat)
987987

988988
if sparse.issparse(X):
989989
X_resampled = sparse.hstack(

0 commit comments

Comments
 (0)