add scikit-learn v0.18 compatibility (#1636)

* add scikit-learn v0.18 compatibility

import KFold & StratifiedKFold from sklearn.model_selection instead of sklearn.cross_validation

* change DeprecationWarning to ImportError

DeprecationWarning isn't an exception, so it should work the other way around.
This commit is contained in:
Jonathan Rahn 2016-10-10 05:37:28 +02:00 committed by Tianqi Chen
parent a64fd74421
commit c8ae52f17a

View File

@ -47,7 +47,11 @@ try:
from sklearn.base import BaseEstimator
from sklearn.base import RegressorMixin, ClassifierMixin
from sklearn.preprocessing import LabelEncoder # noqa
from sklearn.cross_validation import KFold, StratifiedKFold
try:
from sklearn.model_selection import KFold, StratifiedKFold
except ImportError:
from sklearn.cross_validation import KFold, StratifiedKFold
SKLEARN_INSTALLED = True
XGBModelBase = BaseEstimator