Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eli5/sklearn/permutation_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def fit(self, X, y, groups=None, **fit_params):
self.estimator_ = clone(self.estimator)
self.estimator_.fit(X, y, **fit_params)

X = check_array(X)
X = check_array(X, force_all_finite='allow-nan')

if self.cv not in (None, "prefit"):
si = self._cv_scores_importances(X, y, groups=groups, **fit_params)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy >= 1.9.0
scipy
singledispatch >= 3.4.0.3
scikit-learn >= 0.18
scikit-learn >= 0.20
attrs > 16.0.0
jinja2
pip >= 8.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_long_description():
'numpy >= 1.9.0',
'scipy',
'six',
'scikit-learn >= 0.18',
'scikit-learn >= 0.20',
'graphviz',
'tabulate>=0.7.7',
],
Expand Down
12 changes: 11 additions & 1 deletion tests/test_sklearn_permutation_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,14 @@ def test_cv_sample_weight(iris_train):
perm = PermutationImportance(model, cv=5, random_state=42).fit(X, y)

# passing a vector of weights filled with one should be the same as passing no weights
assert (perm.feature_importances_ == perm_weights.feature_importances_).all()
assert (perm.feature_importances_ == perm_weights.feature_importances_).all()

def test_allow_nans(iris_train):
xgboost = pytest.importorskip('xgboost')

X, y, feature_names, target_names = iris_train
X[0, 0] = np.nan

perm = PermutationImportance(xgboost.XGBClassifier(), cv=5)
# There should be not error thrown during fitting of the model
perm.fit(X, y)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; https://github.com/Microsoft/LightGBM/tree/master/python-package#lightgbm-python-package.

[tox]
envlist = py27,py34,py35,py35-nodeps,mypy,py35-extra,py27-extra,py36,py36-extra,py36-legacy,py37-nodeps
envlist = py27,py34,py35,py35-nodeps,mypy,py35-extra,py27-extra,py36,py36-extra,py37-nodeps

[base]
deps=
Expand Down