draw.treeRK: Creates a 'igraph' plot of a 'rktree'

Description Usage Arguments Value Author(s) See Also Examples

View source: R/draw.treeRK.R

Description

Creates a plot of a rktree that was built from the (training) dataset.

The package igraph is loaded internally when this function is called, to aid in generating the plot of a rktree.

DESCRIPTIONS OF THE rktree PLOT:

The resulting plot is a classical decision tree.

The rectangular nodes (or vertices) that contain "=<" symbol are used to describe the splitting criteria applied to that very node while constructing the rktree; for example, in the rktree plot generated by the code shown in the "examples" section below, the node with the label "Petal.Width =< 1.6" indicates that this node was split into a chunk that contains observations with Petal.Width <= 1.6 and a chunk that contains observations with Petal.Width greater than 1.6, in order to construct the rktree.

Any other rectangular nodes (or vertices) that do not contain the "=<" symbol indicate that we have reached an end node, and the text displayed in such node is the actual name of the class type that the rktree model assigns to the observations belonging to that node; for example, in the rktree plot generated by the code shown in the "examples" section below, the vertex with the label "setosa" indicates that the rktree assigns the class type "setosa" to all observations that belong to that particular node.

Usage

1
2
3
4
 draw.treeRK(tr = construct.treeRK(), y.factor.levels,
 font = "Times", node.colour = "white", text.colour = "dark blue",
 text.size = 0.67, tree.vertex.size = 75, tree.title = "Diagram of a Tree",
 title.colour = "dark blue")

Arguments

tr

a construct.treeRK() object (a tree).

y.factor.levels

a y.organizer()$y.factor.levels output.

font

font type used in the rktree plot; default is "Times".

node.colour

colour of the node used in the rktree plot; default is "White".

text.colour

colour of the text used in the rktree plot; default is "Dark Blue".

text.size

size of the text in the rktree plot; default is 0.67.

tree.vertex.size

size of the rktree plot vertices; default is 75.

tree.title

title of the rktree plot; default title is "Diagram of a Tree".

title.colour

colour for the title of the rktree plot; default title colour is "Dark Blue".

Value

An igraph plot of a rktree.

Author(s)

Hyunjin Cho, h56cho@uwaterloo.ca Rebecca Su, y57su@uwaterloo.ca

See Also

mds.plot.forestRK importance.plot.forestRK

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  ## example: iris dataset
  ## load the forestRK package
  library(forestRK)

  ## Numericize the data
  x.train <- x.organizer(iris[,1:4], encoding = "num")[c(1:25,51:75,101:125),]
  y.train <- y.organizer(iris[c(1:25,51:75,101:125),5])$y.new
  y.factor.levels <- y.organizer(iris[c(1:25,51:75,101:125),5])$y.factor.levels

  ## Construct a tree
  # min.num.obs.end.node.tree is set to 5 by default;
  # entropy is set to TRUE by default
  tree.entropy <- construct.treeRK(x.train, y.train)

  # Plot the tree
  draw.treeRK(tree.entropy, y.factor.levels, font="Times",
              node.colour = "black", text.colour = "white", text.size = 0.7,
              tree.vertex.size = 100, tree.title = "Decision Tree",
              title.colour = "dark green")

forestRK documentation built on July 19, 2019, 5:04 p.m.