rggplot2h2oshap

Increasing point size in h2o.shap_summary_plot


I would like to increase point in h2o SHAP summary plot. I tried to modify object that is returned by h2o.shap_summary_plot:

plt=h2o.shap_summary_plot(model, test)
plt=plt+geom_point(size = 4)

Unfortunately old points remain in the background, and position of the new/large points is changed - these are plotted on straight lines: enter image description here


Solution

  • Probably the easiest way to modify this plot is to take the data from it and recreate the plot:

    ggplot(plt$data, aes(.data$feature, .data$contribution, color = .data$normalized_value, text = .data$row)) +
            geom_hline(yintercept = 0, linetype = "dashed") +
            geom_point(position = h2o:::position_jitter_density(), alpha = 0.5, size = 4) +
            scale_color_gradient(low = "#00AAEE", high = "#FF1166") +
            coord_flip() +
            labs(y = "SHAP Contribution", x = "Feature") +
            theme_bw()