Skip to content

Commit 2b653d0

Browse files
committed
InstanceHardnessThreshold StratifiedKFold sklearn 0.18.X bugfix
1 parent 69848ef commit 2b653d0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

imblearn/under_sampling/instance_hardness_threshold.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,14 @@ def _sample(self, X, y):
231231
"""
232232

233233
# Create the different folds
234-
235-
skf = list(StratifiedKFold(y, self.cv, shuffle=False,
236-
random_state=self.random_state))
234+
235+
if hasattr(sklearn, 'model_selection'):
236+
skf = list(StratifiedKFold(n_splits=self.cv, shuffle=False,
237+
random_state=self.random_state).split(X, y))
238+
else:
239+
skf = StratifiedKFold(y, n_folds=self.cv, shuffle=False,
240+
random_state=self.random_state)
241+
237242

238243
probabilities = np.zeros(y.shape[0], dtype=float)
239244

0 commit comments

Comments
 (0)