importance: Extract rfPermute Importance Scores and p-values.

importanceR Documentation

Extract rfPermute Importance Scores and p-values.

Description

The importance function extracts a matrix of the observed importance scores and p-values from the object produced by a call to rfPermute. plotImportance produces a visualization of importance scores as either a barchart or heatmap.

Usage

## S3 method for class 'rfPermute'
importance(x, scale = TRUE, sort.by = NULL, decreasing = TRUE, ...)

plotImportance(
  x,
  plot.type = c("bar", "heatmap"),
  imp.type = NULL,
  scale = TRUE,
  sig.only = FALSE,
  alpha = 0.05,
  n = NULL,
  ranks = TRUE,
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  size = 3,
  plot = TRUE
)

Arguments

x

for importance, an object produced by a call to rfPermute. For plotImportance, either a rfPermute or randomForest model object. If the latter, it must have been run with importance = TRUE.

scale

for permutation based measures, should the measures be divided their "standard errors"?

sort.by

character vector giving the importance metric(s) or p-values to sort by. If NULL, defaults to "MeanDecreaseAccuracy" for classification models and "%IncMSE" for regression models.

decreasing

logical. Should the sort order be increasing or decreasing?

...

arguments to be passed to and from other methods.

plot.type

plot importances as a bar chart or heatmap?

imp.type

character vector listing which importance measures to plot. Can be class names (for classification models) or names of overall importance measures (e.g., "MeanDecreaseAccuracy").

sig.only

Plot only the significant (<= alpha) predictors?

alpha

a number specifying the critical alpha for identifying predictors with importance scores significantly different from random. This parameter is only relevant if rf is a rfPermute object with p-values. Importance measures with p-values less than or equal to alpha will be denoted in barcharts in red and in the heatmap by a white diamond. If set to NULL, significance is not denoted.

n

plot n most important predictors.

ranks

plot ranks instead of actual importance scores?

xlab, ylab

labels for the x and y axes.

main

main title for plot.

size

a value specifying the size of the significance diamond in the heatmap if the p-value <= alpha.

plot

display the plot?

Author(s)

Eric Archer eric.archer@noaa.gov

Examples

data(mtcars)

# A classification model classifying cars to manual or automatic transmission 
am.rp <- rfPermute(factor(am) ~ ., mtcars, ntree = 100, nrep = 50)
  
imp.scaled <- importance(am.rp, scale = TRUE)
imp.scaled

# plot scaled importance scores
plotImportance(am.rp, scale = TRUE)

# plot unscaled and only significant scores
plotImportance(am.rp, scale = FALSE, sig.only = TRUE)


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