rf_parcoor: Parallel coordinates plots of the paths through a random...

Description Usage Arguments See Also Examples

Description

rf_parcoor produces parallel coordinates plots of the paths through a random forest. These visualisations are introduced and explained in our manuscript, a preprint of which is available from arXiv at https://arxiv.org/abs/1706.08702.

Usage

1
2
3
rf_parcoor(all.paths.out, plot = TRUE, all.nodes = TRUE, plot.title = "",
  plot.x.nodes = 7, colour.scale.log = TRUE, colour.scale.lim = 9,
  grey.scale = TRUE)

Arguments

all.paths.out

the result of supplying a random forest to rf_pathfiner.

plot

if TRUE a ggplot2 plot object is returned that is the parallel coordinates plot. If FALSE the dataframe is returned from which a parallel coordinates plot can be produced with ggplot2 (see examples below).

all.nodes

If TRUE the parallel coordinates plot depicts all nodes on all paths through the random forest. If FALSE the parallel coordinates plot depicts the first plot.x.nodes nodes along all paths through the random forest.

plot.title

a character string specifying the title to display on the plot.

plot.x.nodes

the number of nodes along all paths to represent with parallel vertical axes

colour.scale.log

If TRUE the colour scale for the path selection frequencies uses a logarithmic scale. If FALSE the colour bar does not use a logarithmic scale.

colour.scale.lim

The upper bound of the colour scale (if colour.scale.log = TRUE supply the logarithm of the upper bound desired to this argument).

grey.scale

If TRUE a grey scale is used in place of a colour scale to represent the path selection frequencies. If FALSE a colour scale is used to represent the path selection frequencies.

See Also

rf_pathfinder

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# example 1:
library(mlbench)
data(Satellite)
library(randomForest)
rf.1 <- randomForest(classes ~ ., data = Satellite, mtry = 8, keep.forest = TRUE, ntree = 25, importance = TRUE)
rf.1.all.paths <- rf_pathfinder(rf = rf.1)
rf.pc <- rf_parcoor(all.paths.out = rf.1.all.paths, plot = TRUE, all.nodes = TRUE, plot.title = '', grey.scale = FALSE)
rf.pc
# custom ordering of covariates on the vertical axis:
rf.pc + ggplot2::ylim(paste(c('Terminus', paste('x',1:36,sep = '.'))))

# grey scale version:
rf.pc.grey <- rf_parcoor(all.paths.out = rf.1.all.paths, plot = TRUE, all.nodes = TRUE, plot.title = '', grey.scale = TRUE)
rf.pc.grey

# interactive version with plotly (should work once geom_GeomCurve() is implemented in plotly)
# library(plotly)
# ggplotly(p = p1)

# example 2:
data(iris)
library(randomForest)
rf.2 <- randomForest(Species ~ ., data = iris, mtry = 2, keep.forest = TRUE, ntree = 100, importance = TRUE)
rf.2.all.paths <- rf_pathfinder(rf = rf.2)
rf.pc.2 <- rf_parcoor(all.paths.out = rf.2.all.paths, plot = TRUE, all.nodes = TRUE, plot.title = '', grey.scale = TRUE)
rf.pc.2

brfitzpatrick/forestviews documentation built on May 14, 2019, 8:17 a.m.