Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermutationImportance does not allow NaNs #380

Closed
Matgrb opened this issue May 22, 2020 · 1 comment
Closed

PermutationImportance does not allow NaNs #380

Matgrb opened this issue May 22, 2020 · 1 comment

Comments

@Matgrb
Copy link

Matgrb commented May 22, 2020

In the current version, eli5 does not allow NaNs in X. However, some models handle NaNs very well e.g. XGBClassifier or HistGradientBoostingClassifier from sklearn.

The following code allows to reproduce the issue:

import numpy as np
from eli5.sklearn import PermutationImportance

from sklearn.experimental import enable_hist_gradient_boosting
from sklearn.ensemble import HistGradientBoostingClassifier

X, y = load_iris(return_X_y=True)
X[0,0] = np.nan

perm = PermutationImportance(HistGradientBoostingClassifier(), cv=5)
perm.fit(X, y)

I suppose PermutationImportance should allow for NaNs, since if the used classifier does not allow for it, it will throw the same error anyway.

I would change the following line in eli5.sklearn.permutation_importance:

197:   X = check_array(X)

into:

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

This would require increasing requirements sklearn to 0.20.0

Other way would be without modifying requirements

197:   X = check_array(X, force_all_finite=False)

As part of the issue, I would also like to implement a quick unit test.

@Matgrb
Copy link
Author

Matgrb commented May 22, 2020

Just found now that it is a duplicate of #262

@Matgrb Matgrb closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant