GetPartialData.Rd
Computes the partial dependence for several covariates in a conditional random forest and gathers them into a single data frame.
GetPartialData(object, xnames=NULL, ice = FALSE, center = FALSE,
grid.resolution = NULL, quantiles = TRUE, probs = 1:9/10,
trim.outliers = FALSE, which.class = 1L, prob = TRUE,
pred.fun = NULL, parallel = FALSE, paropts = NULL)
An object as returned by cforest
(or fastcforest
).
A character vector of the covariates for which to compute the partial dependence. If NULL (default), partial dependence is computed for all the covariates in the model.
Logical indicating whether or not to compute individual conditional expectation (ICE) curves. Default is FALSE. See Goldstein et al. (2014) for details.
Logical indicating whether or not to produce centered ICE curves (c-ICE curves). Only used when ice = TRUE. Default is FALSE. See Goldstein et al. (2014) for details.
Integer giving the number of equally spaced points to use for the continuous variables listed in xnames
. If left NULL, it will default to the minimum between 51 and the number of unique data points for each of the continuous independent variables listed in xnames
.
Logical indicating whether or not to use the sample quantiles of the continuous predictors listed in xnames
. If quantiles = TRUE
and grid.resolution = NULL
(default), the sample quantiles will be used to generate the grid of joint values for which the partial dependence is computed.
Numeric vector of probabilities with values in [0,1]. (Values up to 2e-14 outside that range are accepted and moved to the nearby endpoint.) Default is 1:9/10
which corresponds to the deciles of the predictor variables. These specify which quantiles to use for the continuous predictors listed in xnames
when quantiles = TRUE
.
Logical indicating whether or not to trim off outliers from the continuous predictors listed in xnames
(using the simple boxplot method) before generating the grid of joint values for which the partial dependence is computed. Default is FALSE.
Integer specifying which column of the matrix of predicted probabilities to use as the "focus" class. Default is to use the first class. Only used for classification problems.
Logical indicating whether or not partial dependence for classification problems should be returned on the probability scale, rather than the centered logit. If FALSE, the partial dependence function is on a scale similar to the logit. Default is TRUE.
Optional prediction function that requires two arguments: object
and newdata
. If specified, then the function must return a single prediction or a vector of predictions (i.e., not a matrix or data frame). Default is NULL.
Logical indicating whether or not to run partial
in parallel using a backend provided by the foreach
package. Default is FALSE.
List containing additional options to be passed onto foreach
when parallel = TRUE
.
The computation of partial dependence uses partial
function from pdp
package for each covariate. The results are then gathered and reshaped into a friendly data frame format.
A data frame with covariates, their categories and their partial dependence effects.
J. H. Friedman. Greedy function approximation: A gradient boosting machine. Annals of Statistics, 29: 1189-1232, 2001.
Goldstein, A., Kapelner, A., Bleich, J., and Pitkin, E., Peeking Inside the Black Box: Visualizing Statistical Learning With Plots of Individual Conditional Expectation. (2014) Journal of Computational and Graphical Statistics, 24(1): 44-65, 2015.
partial
,GetAleData
,GetInteractionStrength
data(iris)
iris2 = iris
iris2$Species = factor(iris$Species == "versicolor")
iris.cf = party::cforest(Species ~ ., data = iris2,
controls = party::cforest_unbiased(mtry=2, ntree=50))
GetPartialData(iris.cf)
#> var cat value
#> 1 Sepal.Length 4.8 0.6785881
#> 2 Sepal.Length 5 0.6707958
#> 3 Sepal.Length 5.27 0.6612085
#> 4 Sepal.Length 5.6 0.6348910
#> 5 Sepal.Length 5.8 0.6306173
#> 6 Sepal.Length 6.1 0.6383541
#> 7 Sepal.Length 6.3 0.6479789
#> 8 Sepal.Length 6.52 0.6497333
#> 9 Sepal.Length 6.9 0.6492133
#> 10 Sepal.Width 2.5 0.5420724
#> 11 Sepal.Width 2.7 0.5473550
#> 12 Sepal.Width 2.8 0.5517023
#> 13 Sepal.Width 3 0.6492865
#> 14 Sepal.Width 3 0.6492865
#> 15 Sepal.Width 3.1 0.6880432
#> 16 Sepal.Width 3.2 0.7177889
#> 17 Sepal.Width 3.4 0.7576480
#> 18 Sepal.Width 3.61 0.7704474
#> 19 Petal.Length 1.4 0.7950855
#> 20 Petal.Length 1.5 0.7950855
#> 21 Petal.Length 1.7 0.7847807
#> 22 Petal.Length 3.9 0.4054920
#> 23 Petal.Length 4.35 0.4061269
#> 24 Petal.Length 4.64 0.4477690
#> 25 Petal.Length 5 0.6479488
#> 26 Petal.Length 5.32 0.6777901
#> 27 Petal.Length 5.8 0.6777901
#> 28 Petal.Width 0.2 0.5810492
#> 29 Petal.Width 0.2 0.5810492
#> 30 Petal.Width 0.4 0.5615213
#> 31 Petal.Width 1.16 0.4790631
#> 32 Petal.Width 1.3 0.4790631
#> 33 Petal.Width 1.5 0.5115509
#> 34 Petal.Width 1.8 0.8262246
#> 35 Petal.Width 1.9 0.8389396
#> 36 Petal.Width 2.2 0.8406063