| 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 summary plot} |
| 7 |
\usage{ |
| 8 |
xgb.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 |
|
| 20 |
xgb.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}{The data to explain as a \code{matrix}, \code{dgCMatrix}, or \code{data.frame}.} |
| 34 |
|
| 35 |
\item{shap_contrib}{Matrix of SHAP contributions of \code{data}. |
| 36 |
The default (\code{NULL}) computes it from \code{model} and \code{data}.} |
| 37 |
|
| 38 |
\item{features}{Vector of column indices or feature names to plot. When \code{NULL} |
| 39 |
(default), the \code{top_n} most important features are selected by \code{\link[=xgb.importance]{xgb.importance()}}.} |
| 40 |
|
| 41 |
\item{top_n}{How many of the most important features (<= 100) should be selected? |
| 42 |
By default 1 for SHAP dependence and 10 for SHAP summary. |
| 43 |
Only used when \code{features = NULL}.} |
| 44 |
|
| 45 |
\item{model}{An \code{xgb.Booster} model. Only required when \code{shap_contrib = NULL} or |
| 46 |
\code{features = NULL}.} |
| 47 |
|
| 48 |
\item{trees}{Passed to \code{\link[=xgb.importance]{xgb.importance()}} when \code{features = NULL}.} |
| 49 |
|
| 50 |
\item{target_class}{Only relevant for multiclass models. The default (\code{NULL}) |
| 51 |
averages the SHAP values over all classes. Pass a (0-based) class index |
| 52 |
to show only SHAP values of that class.} |
| 53 |
|
| 54 |
\item{approxcontrib}{Passed to \code{\link[=predict.xgb.Booster]{predict.xgb.Booster()}} when \code{shap_contrib = NULL}.} |
| 55 |
|
| 56 |
\item{subsample}{Fraction of data points randomly picked for plotting. |
| 57 |
The default (\code{NULL}) will use up to 100k data points.} |
| 58 |
} |
| 59 |
\value{ |
| 60 |
A \code{ggplot2} object. |
| 61 |
} |
| 62 |
\description{ |
| 63 |
Visualizes SHAP contributions of different features. |
| 64 |
} |
| 65 |
\details{ |
| 66 |
A point plot (each point representing one observation from \code{data}) is |
| 67 |
produced for each feature, with the points plotted on the SHAP value axis. |
| 68 |
Each point (observation) is coloured based on its feature value. |
| 69 |
|
| 70 |
The plot allows to see which features have a negative / positive contribution |
| 71 |
on the model prediction, and whether the contribution is different for larger |
| 72 |
or smaller values of the feature. Inspired by the summary plot of |
| 73 |
\url{https://github.com/shap/shap}. |
| 74 |
} |
| 75 |
\examples{ |
| 76 |
# See examples in xgb.plot.shap() |
| 77 |
|
| 78 |
} |
| 79 |
\seealso{ |
| 80 |
\code{\link[=xgb.plot.shap]{xgb.plot.shap()}}, \code{\link[=xgb.ggplot.shap.summary]{xgb.ggplot.shap.summary()}}, |
| 81 |
and the Python library \url{https://github.com/shap/shap}. |
| 82 |
} |