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

Failed to guess the type of shap explainer to use #10

Closed
raybellwaves opened this issue Nov 11, 2020 · 5 comments
Closed

Failed to guess the type of shap explainer to use #10

raybellwaves opened this issue Nov 11, 2020 · 5 comments

Comments

@raybellwaves
Copy link
Contributor

First time using this code. Thanks.

When I try

explainer = RegressionExplainer(model, X_test, y_test)

I get

ValueError: Failed to guess the type of shap explainer to use. Please explicitly pass either shap='tree', 'linear', deep' or 'kernel'.

i'm not sure where to put this

@oegedijk
Copy link
Owner

Ah, yeah, I could clarify that error message. In an earlier iteration of explainerdashboard you had to pass a parameter on what kind of shap explainer your model needed (shap.TreeExplainer, shap.LinearExplainer, shap.KernelExplainer, etc), by passing a parameter to the explainer e.g. shap='tree'.

Then I made it default to shap='guess' where the explainer tries to guess what kind of shap explainer is needed from the name of the model class. In case it fails to do this you get the above message.

What is the model that you fitted?

If it's a linear model you would pass it for example as:

explainer = RegressionExplainer(model, X_test, y_test, shap='linear')

@raybellwaves
Copy link
Contributor Author

Thanks. It's a sklearn.ensemble.RandomForestRegressor

so i'll use

explainer = RegressionExplainer(model, X_test, y_test, shap='tree')

@oegedijk
Copy link
Owner

That's weird, that should definitely be detected (and it works in the tests that use a RandomForestRegressor as well).

What do you see when your print(str(type(model)))?

For reference, these models should all automatically get shap='tree' and shap='linear':

tree_models = ['RandomForestClassifier', 'RandomForestRegressor',
'DecisionTreeClassifier', 'DecisionTreeRegressor',
'ExtraTreesClassifier', 'ExtraTreesRegressor',
'GradientBoostingClassifier', 'GradientBoostingRegressor',
'HistGradientBoostingClassifier', 'HistGradientBoostingRegressor',
'XGBClassifier', 'XGBRegressor',
'LGBMClassifier', 'LGBMRegressor',
'CatBoostClassifier', 'CatBoostRegressor',
'NGClassifier', 'NGBRegressor',
'GBTClassifier', ' GBTRegressor',
'IsolationForest'
]
linear_models = ['LinearRegression', 'LogisticRegression',
'Ridge', 'Lasso', 'ElasticNet']

@oegedijk oegedijk reopened this Nov 11, 2020
@raybellwaves
Copy link
Contributor Author

Actually this follows #11

Probably because it was a pipeline it's wasn't familiar with the type of model.

@oegedijk
Copy link
Owner

Ah, got it. Will add supporting sklearn pipelines to the roadmap!

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

2 participants