dplot3_cart: Plot 'rpart' decision trees

View source: R/dplot3_cart.R

dplot3_cartR Documentation

Plot rpart decision trees

Description

Plot rpart decision trees using data.tree::plot.Node

Usage

dplot3_cart(
  object,
  col.positive = "#F48024DD",
  col.negative = "#18A3ACDD",
  col.lo = "#80ffff",
  col.mid = "gray20",
  col.hi = "#F4A0FF",
  node.col = "#666666",
  node.shape = "none",
  node.labels = TRUE,
  node.cond = TRUE,
  node.prob = TRUE,
  node.estimate = NULL,
  node.n = TRUE,
  edge.col = "#999999",
  edge.width = 2,
  edge.labels = FALSE,
  arrowhead = "vee",
  layout = "dot",
  drop.leaves = FALSE,
  rankdir = "TB",
  splines = "polyline",
  fontname = "helvetica",
  bg.color = "white",
  overlap = "false",
  prune = FALSE,
  rpart.cp = NULL,
  verbose = TRUE
)

Arguments

object

Either rpart object or rtMod object trained with s_CART

col.positive

Color for outcome positive.

col.negative

Color for negative outcome.

col.lo

Low color for estimated outcome

col.mid

Middle color for estimated outcome

col.hi

High color for estimated outcome

node.col

Color for non-terminal leaves.

node.shape

Shape of node. Default = "none"

node.labels

Logical: If TRUE, print the node labels.

node.cond

Logical: If TRUE, print the splitting condition inside each node.

node.prob

Logical: If TRUE, print the probability estimate for the first class of the outcome inside each node.

node.estimate

Logical: If TRUE, print the estimated outcome level inside each node.

node.n

Logical: If TRUE, print the number of cases (from training data) that matched this condition

edge.col

Color for edges.

edge.width

Width of edges.

edge.labels

Logical: If TRUE, print the splitting condition on the edge.

arrowhead

Character: Arrowhead shape.

layout

Character: Passed to data.tree::SetGraphStyle

drop.leaves

Logical: If TRUE, position leaves at the bottom of the plot.

rankdir

Character: Passed to data.tree::SetGraphStyle

splines

Character: Passed to data.tree::SetGraphStyle

fontname

Character: Passed to data.tree::SetGraphStyle

bg.color

Background color.

overlap

Character: Passed to data.tree::SetGraphStyle

prune

Logical: If TRUE, prune tree using rpart::prune.rpart

rpart.cp

Numeric: Complexity parameter for pruning. If NULL, no pruning is performed.

verbose

Logical: If TRUE, print messages.

Details

If you want to show split conditions as edge labels (edge.labels = TRUE), it is recommened to set rankdir = "LR" and node.cond = FALSE. Edge labels in graphviz are shown to the right of the edge when rankdir = "TB" and above when rankdir = "LR".

Author(s)

E.D. Gennatas


egenn/rtemis documentation built on May 4, 2024, 7:40 p.m.