Learn R Programming

rfPermute (version 2.5.2)

plotProximity: Plot Random Forest Proximity Scores

Description

Create a plot of Random Forest proximity scores using multi-dimensional scaling.

Usage

plotProximity(
  x,
  dim.x = 1,
  dim.y = 2,
  class.cols = NULL,
  legend.type = c("legend", "label", "none"),
  legend.loc = c("top", "bottom", "left", "right"),
  point.size = 2,
  circle.size = 8,
  circle.border = 1,
  group.type = c("ellipse", "hull", "contour", "none"),
  group.alpha = 0.3,
  ellipse.level = 0.95,
  n.contour.grid = 100,
  label.size = 4,
  label.alpha = 0.7,
  plot = TRUE
)

Value

a list with:

prox.mds

the MDS scores of the selected dimensions

g

ggplot object

Arguments

x

a rfPermute or randomForest model object.

dim.x, dim.y

numeric values giving x and y dimensions to plot from multidimensional scaling of proximity scores.

class.cols

vector of colors to use for each class.

legend.type

type of legend to use to label classes.

legend.loc

character keyword specifying location of legend. Can be "bottom", "top", "left", "right".

point.size

size of central points. Set to NULL for no points.

circle.size

size of circles around points indicating classification. Set to NULL for no circles.

circle.border

width of circle border.

group.type

type of grouping to display. Ignored for regression models.

group.alpha

value giving alpha transparency level for group shading. Setting to 0 produces no shading.

ellipse.level

the confidence level at which to draw the ellipse.

n.contour.grid

number of grid points for contour lines.

label.size

size of label if legend.type = `label`.

label.alpha

transparency of label background.

plot

logical determining whether or not to show plot.

Author

Eric Archer eric.archer@noaa.gov

Details

Produces a scatter plot of proximity scores for dim.x and dim.y dimensions from a multidimensional scale (MDS) conversion of proximity scores from a randomForest object. For classification models, points are colored according to original (inner) and predicted (outer) class.

Examples

Run this code
library(randomForest)
data(symb.metab)

rf <- randomForest(type ~ ., symb.metab, proximity = TRUE)

# With confidence ellipses
plotProximity(rf)

# With convex hulls
plotProximity(rf, group.type = "hull")

# With contours
plotProximity(rf, group.type = "contour")

# Remove the points and just show ellipses
plotProximity(rf, point.size = NULL, circle.size = NULL, group.alpha = 0.5)

# Labels instead of a legend
plotProximity(rf, legend.type = "label", point.size = NULL, circle.size = NULL, group.alpha = 0.5)

Run the code above in your browser using DataLab