Skip to content

Add SHAP Example for Optuna#320

Closed
ParagEkbote wants to merge 3 commits intooptuna:mainfrom
ParagEkbote:Add-Shap_Example
Closed

Add SHAP Example for Optuna#320
ParagEkbote wants to merge 3 commits intooptuna:mainfrom
ParagEkbote:Add-Shap_Example

Conversation

@ParagEkbote
Copy link
Copy Markdown
Contributor

@ParagEkbote ParagEkbote commented Apr 23, 2025

Description of the changes

Refs #317

This PR adds an example showing the integration of SHAP with optuna. We use the iris flower dataset and RandomForestClassifier as the model. The following results are observed, and we also plot the following visualizations:

  1. A feature importance summary across all classes

Best trial:
Value: 0.9500
Params:
n_estimators: 96
max_depth: 20
max_features: None
Training final model with best parameters...
Validation Accuracy: 1.0000
Explaining predictions with SHAP...
Explaining sample 0:
Actual class: 1 (versicolor)
Predicted class: 1 (versicolor)

Could you please review?

cc: @c-bata

@nabenabe0928
Copy link
Copy Markdown
Contributor

nabenabe0928 commented Apr 28, 2025

@ParagEkbote
Thank you for the PR!
We discussed internally and actually want to enhance the doc here instead of adding the example.

By design, the evaluator.evaluate method is not supposed to be called by users, we want to have an example of calling plot_param_importances in the Shapley doc.

Important

Please use a square function $f(x, y) = x^2 + y^2$ as an objective function to make examples more concise.

@ParagEkbote ParagEkbote deleted the Add-Shap_Example branch April 28, 2025 16:42
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

Successfully merging this pull request may close these issues.

2 participants