partialDepAll: Partial Dependence Spark Lines (multiple variables)

Description Usage Arguments Value See Also Examples

Description

Calculate the partial dependence of a predictor variable on the response variable from a random forest classification model. Rather than sequence through values of the predictor variable of interest and keep the other predictors at their median, this partial dependence technique creates replicates of the entire dataset for each level of the x variable of interest from it's min to max. This gives a more realistic idea of the magnitude and direction of the x variable on the response.

Usage

1
2
partialDepAll(model, df, n = 10, xvars = NULL, target.class = "1",
  ci = c(0.75), plot = T, data = T, plot.yaxis.fixed = T, wordy = T)

Arguments

model

model object used to generate predictions. Currently only built and tested for random forest.

df

data.frame or data.table used to generate predictions with model

n

numeric of length one; number of values between the min and max of xvar to score the model. Note: this number is also how many replicates of df must be created and stored in memory. Default is 10.

xvars

character vector; the x variables in df to assess for partial dependence with the response variable from model. Defaults to choosing all variables from model.

target.class

character: Which category (class) of the target variable to use for predictions

ci

numeric: specify any confidence intervals around the median response.

plot

logical: plot sparklines (TRUE), or no (FALSE)

data

logical: return summary table of output. yes (TRUE), or no (FALSE)

plot.yaxis.fixed

logical: TRUE uses same yaxis for all x variables (biggest max and smallest min across all variables). code\FALSE uses variable specific axes.

wordy

logical: print progress to the console

Value

list of output and plot

See Also

partialDep

Examples

1
2
3
4
5
6
7
library('randomForest')
library('data.table')
library('ggplot2')
DF <- mtcars
DF$vs <- factor(DF$vs)
rf <- randomForest(vs~mpg+cyl+drat+qsec+disp+gear+carb+hp, DF, ntrees=100)
pda <- partialDepAll(model=rf, df=DF, n=10)

brooksandrew/Rsenal documentation built on May 13, 2019, 7:50 a.m.