iterative / iterative/studio-support

Add support for shap interactive plots

Open
#82 3 comments 3 reactions 0 assignees View on GitHub
feature request
Dominant language
No language data
Stars
17
Forks
1
PR merge metrics
No merged PRs in 30d

Description

[Shap](https://github.com/slundberg/shap) is a powerful library for model interpretation that creates interactive plots. These plots can be saved as HTML to embed somewhere else, as long as the required JavaScript is loaded. While exporting the plots as a static image file is possible, some functionality is lost.

I'm unsure of how plots are loaded into Studio, but it seems possible to modify the way `dvc_plots/index.html` is created to include:
- The JavaScript library of Shap
- The dumped Shap plot HTML

The HTML of the plot can be obtained as follows:
```py
# model: trained model to explain
# X: training data

explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X)
shap_plot = shap.force_plot(explainer.expected_value, shap_values, X)

shap_plot_html = shap_plot.html() # HTML code of the plot
```

The JavaScript can be obtained with the following command:
```py
shap.getjs()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.