Skip to content

Commit c4777f5

Browse files
committed
fix
1 parent b63e7ce commit c4777f5

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

imblearn/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,16 @@ def fit_resample(self, X, y):
300300

301301
if self._y_name is not None:
302302
y_ = pd.Series(y_, dtype=self._y_dtype, name=self._y_name)
303+
304+
if binarize_y:
305+
if len(output) == 2:
306+
return X_, y_
307+
return X_, y_, output[2]
303308
else:
304309
X_, y_ = output[0], output[1]
305-
306-
if binarize_y:
307310
if len(output) == 2:
308311
return X_, y_
309312
return X_, y_, output[2]
310-
if len(output) == 2:
311-
return X_, y_
312-
return X_, y_, output[2]
313313

314314
def _fit_resample(self, X, y):
315315
func = _identity if self.func is None else self.func

imblearn/over_sampling/_smote.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,22 @@ def _check_X_y(self, X, y):
892892
"""Overwrite the checking to let pass some string for categorical
893893
features.
894894
"""
895-
# store the columns name to reconstruct a dataframe
896-
self._columns = X.columns if hasattr(X, "loc") else None
895+
if hasattr(X, "loc"):
896+
# store information to build dataframe
897+
self._X_columns = X.columns
898+
self._X_dtypes = X.dtypes
899+
else:
900+
self._X_columns = None
901+
self._X_dtypes = None
902+
903+
if hasattr(y, "loc"):
904+
# store information to build a series
905+
self._y_name = y.name
906+
self._y_dtype = y.dtype
907+
else:
908+
self._y_name = None
909+
self._y_dtype = None
910+
897911
y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
898912
X, y = check_X_y(X, y, accept_sparse=["csr", "csc"], dtype=None)
899913
return X, y, binarize_y

0 commit comments

Comments
 (0)