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

TypeError: list indices must be integers or slices, not tuple when creating scatter plot of binary classification model #2811

Open
michiel98fjhsad opened this issue Dec 20, 2022 · 0 comments

Comments

@michiel98fjhsad
Copy link

I have a binary classification problem for which I have developed a LightGBM classifier. I would like to plot global SHAP contributions for the X most important features, as in the scatter plot documentation the code shap.plots.scatter(shap_values[:, shap_values.abs.mean(0).argsort[-1]]) produces
image

My attempt is as follows:

clf_final = lightgbm.LGBMClassifier(**RSCV.best_estimator_.get_params())
clf_final.fit(X_train, y_train)

# compute SHAP values
explainer_LGB = shap.TreeExplainer(clf_final)
shap_values_LGB = explainer_LGB.shap_values(X_train)
shap.plots.scatter(shap_values_LGB[0:,"pet_mean_lag_t-6"])

But it produces the error message: TypeError: list indices must be integers or slices, not tuple

How could I get the desired plot for some of my features?

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