1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/xgb.plot.shap.R
3\name{xgb.shap.data}
4\alias{xgb.shap.data}
5\title{Prepare data for SHAP plots. To be used in xgb.plot.shap, xgb.plot.shap.summary, etc.
6Internal utility function.}
7\usage{
8xgb.shap.data(
9  data,
10  shap_contrib = NULL,
11  features = NULL,
12  top_n = 1,
13  model = NULL,
14  trees = NULL,
15  target_class = NULL,
16  approxcontrib = FALSE,
17  subsample = NULL,
18  max_observations = 1e+05
19)
20}
21\arguments{
22\item{data}{data as a \code{matrix} or \code{dgCMatrix}.}
23
24\item{shap_contrib}{a matrix of SHAP contributions that was computed earlier for the above
25\code{data}. When it is NULL, it is computed internally using \code{model} and \code{data}.}
26
27\item{features}{a vector of either column indices or of feature names to plot. When it is NULL,
28feature importance is calculated, and \code{top_n} high ranked features are taken.}
29
30\item{top_n}{when \code{features} is NULL, top_n [1, 100] most important features in a model are taken.}
31
32\item{model}{an \code{xgb.Booster} model. It has to be provided when either \code{shap_contrib}
33or \code{features} is missing.}
34
35\item{trees}{passed to \code{\link{xgb.importance}} when \code{features = NULL}.}
36
37\item{target_class}{is only relevant for multiclass models. When it is set to a 0-based class index,
38only SHAP contributions for that specific class are used.
39If it is not set, SHAP importances are averaged over all classes.}
40
41\item{approxcontrib}{passed to \code{\link{predict.xgb.Booster}} when \code{shap_contrib = NULL}.}
42
43\item{subsample}{a random fraction of data points to use for plotting. When it is NULL,
44it is set so that up to 100K data points are used.}
45}
46\value{
47A list containing: 'data', a matrix containing sample observations
48  and their feature values; 'shap_contrib', a matrix containing the SHAP contribution
49  values for these observations.
50}
51\description{
52Prepare data for SHAP plots. To be used in xgb.plot.shap, xgb.plot.shap.summary, etc.
53Internal utility function.
54}
55\keyword{internal}
56