Orange3-Shap Documentation

Widgets

Shap summary plot

_images/shap_summary.png

Visualize shap summary.

Note

At this moment, this widget only accepts models generated by RandomForest(Regressor,Classifier).

Signals

Inputs
  • Data
  • Model
Outputs
  • Top Features

Description

In this widget, you can visualize the shap summary.

_images/shap_summary_results.png

One can select the number of top features.

Shap single plot

_images/shap_single.png

Visualize shap single prediction explanation.

Note

At this moment, this widget only accepts models generated by RandomForest(Regressor,Classifier).

Signals

Inputs
  • Data
  • Model
Outputs
  • Top Features

Description

In this widget, you can visualize the shap single prediction explanation plot.

_images/shap_single_results.png

One can select the sample.

Python Scripting

Scripting

Load libraries.

>>> from orangecontrib.oshap.widgets.OWShapSingle import OWShapSingle
>>> from orangecontrib.oshap.widgets.OWShapSummary import OWShapSummary
>>> from sklearn.ensemble.forest import RandomForestRegressor as SKL_RF
>>> from Orange.regression.random_forest import RandomForestRegressor
>>> from Orange.widgets.utils.widgetpreview import WidgetPreview
>>> from Orange.data import Table

Load data and model.

>>> data = Table('housing')
>>> rf = SKL_RF(n_estimators=10)
>>> rf.fit(data.X, data.Y)
>>> model_rf = RandomForestRegressor(rf)

Explain single prediction.

>>> WidgetPreview(OWShapSingle).run(set_data=data, set_model=model_rf)

Explain general prediction.

>>> WidgetPreview(OWShapSummary).run(set_data=data, set_model=model_rf)

Indices and tables