Skip to content

Commit c8260ed

Browse files
committed
function without raise/except calling
1 parent 2136348 commit c8260ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

imblearn/under_sampling/instance_hardness_threshold.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@
77

88
import numpy as np
99
from six import string_types
10+
import sklearn
1011
from sklearn.base import ClassifierMixin
1112
from sklearn.ensemble import RandomForestClassifier
1213

1314
from ..base import BaseBinarySampler
1415

1516

1617
def _get_cv_splits(X, y, cv, random_state):
17-
try:
18+
if hasattr(sklearn, 'model_selection'):
1819
from sklearn.model_selection import StratifiedKFold
1920
cv_iterator = StratifiedKFold(
2021
n_splits=cv, shuffle=False, random_state=random_state).split(X, y)
21-
except:
22+
else:
2223
from sklearn.cross_validation import StratifiedKFold
2324
cv_iterator = StratifiedKFold(
2425
y, n_folds=cv, shuffle=False, random_state=random_state)
26+
2527
return cv_iterator
2628

2729

0 commit comments

Comments
 (0)