1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/xgb.ggplot.R, R/xgb.plot.shap.R
3\name{xgb.ggplot.shap.summary}
4\alias{xgb.ggplot.shap.summary}
5\alias{xgb.plot.shap.summary}
6\title{SHAP contribution dependency summary plot}
7\usage{
8xgb.ggplot.shap.summary(
9  data,
10  shap_contrib = NULL,
11  features = NULL,
12  top_n = 10,
13  model = NULL,
14  trees = NULL,
15  target_class = NULL,
16  approxcontrib = FALSE,
17  subsample = NULL
18)
19
20xgb.plot.shap.summary(
21  data,
22  shap_contrib = NULL,
23  features = NULL,
24  top_n = 10,
25  model = NULL,
26  trees = NULL,
27  target_class = NULL,
28  approxcontrib = FALSE,
29  subsample = NULL
30)
31}
32\arguments{
33\item{data}{data as a \code{matrix} or \code{dgCMatrix}.}
34
35\item{shap_contrib}{a matrix of SHAP contributions that was computed earlier for the above
36\code{data}. When it is NULL, it is computed internally using \code{model} and \code{data}.}
37
38\item{features}{a vector of either column indices or of feature names to plot. When it is NULL,
39feature importance is calculated, and \code{top_n} high ranked features are taken.}
40
41\item{top_n}{when \code{features} is NULL, top_n [1, 100] most important features in a model are taken.}
42
43\item{model}{an \code{xgb.Booster} model. It has to be provided when either \code{shap_contrib}
44or \code{features} is missing.}
45
46\item{trees}{passed to \code{\link{xgb.importance}} when \code{features = NULL}.}
47
48\item{target_class}{is only relevant for multiclass models. When it is set to a 0-based class index,
49only SHAP contributions for that specific class are used.
50If it is not set, SHAP importances are averaged over all classes.}
51
52\item{approxcontrib}{passed to \code{\link{predict.xgb.Booster}} when \code{shap_contrib = NULL}.}
53
54\item{subsample}{a random fraction of data points to use for plotting. When it is NULL,
55it is set so that up to 100K data points are used.}
56}
57\value{
58A \code{ggplot2} object.
59}
60\description{
61Compare SHAP contributions of different features.
62}
63\details{
64A point plot (each point representing one sample from \code{data}) is
65produced for each feature, with the points plotted on the SHAP value axis.
66Each point (observation) is coloured based on its feature value. The plot
67hence allows us to see which features have a negative / positive contribution
68on the model prediction, and whether the contribution is different for larger
69or smaller values of the feature. We effectively try to replicate the
70\code{summary_plot} function from https://github.com/slundberg/shap.
71}
72\examples{
73# See \code{\link{xgb.plot.shap}}.
74}
75\seealso{
76\code{\link{xgb.plot.shap}}, \code{\link{xgb.ggplot.shap.summary}},
77  \url{https://github.com/slundberg/shap}
78}
79