plotImpPreds: Plot Important Predictor Distribution

View source: R/plotImpPreds.R

plotImpPredsR Documentation

Plot Important Predictor Distribution

Description

For classification models, plot distribution of predictor variables on classes sorted by order of importance in model.

Usage

plotImpPreds(
  x,
  df,
  class.col,
  imp.type = NULL,
  max.vars = 16,
  scale = TRUE,
  size = 1,
  point.alpha = 0.2,
  violin.alpha = 0.5,
  plot = TRUE
)

Arguments

x

a rfPermute or randomForest model object.

df

data.frame with predictors in rf model.

class.col

response column name in df.

imp.type

character string representing importance type to use for sorting predictors.

max.vars

number of variables to plot (from most important to least).

scale

For permutation based importance measures, should they be divided their "standard errors"?

size, point.alpha, violin.alpha

controls size of points and alpha values (transparency) for points and violin plots.

plot

display the plot?

Value

the ggplot2 object is invisibly returned.

Note

If the model in x is from randomForest and was run with importance = TRUE, then 'MeanDecreaseAccuracy' is used as the default importance measure for sorting. Otherwise, 'MeanDecreaseGini' is used.

Author(s)

Eric Archer eric.archer@noaa.gov

Examples

library(randomForest)
data(mtcars)

df <- mtcars
df$am <- factor(df$am)

rf <- randomForest(am ~ ., df, importance = TRUE)
plotImpPreds(rf, df, "am")


rfPermute documentation built on Aug. 24, 2023, 1:08 a.m.