Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

SHAP dependence plots (scatter with a regression trend line and Histogram)

$
0
0

I want to draw shap partial dependence plots with regression lines and histograms, similar to the figure from the referenced article below.

Here is the Figure

**Reference Article **: Kim, S.H., Jeon, E.T., Yu, S., Oh, K., Kim, C.K., Song, T.J., Kim, Y.J., Heo, S.H., Park, K.Y., Kim, J.M. and Park, J.H., 2021. Interpretable machine learning for early neurological deterioration prediction in atrial fibrillation-related stroke. Scientific reports, 11(1), p.20610.

How can I modify the original SHAP dependence plot code below to include the regression line and histogram as shown in the figure above? This code can only give me the scatter plot.

rf = RandomForestClassifier(n_estimators=500)rf.fit(X_train, y_train)explainer = shap.TreeExplainer(rf)shap_values = explainer.shap_values(X_test)shap.dependence_plot("var_1", shap_values[1], X_test, interaction_index=None, color='orange',show=False)

RegardsUmer

I tried to add a separate axis. However, it did not work.ax = plt.gca()


Viewing all articles
Browse latest Browse all 23131

Trending Articles