Learn R Programming

FFTrees (version 1.7.0)

plot.FFTrees: Plot an FFTrees object

Description

plot.FFTrees visualizes an FFTrees object created by the FFTrees function.

plot.FFTrees is the main plotting function of the FFTrees package and called when evaluating the generic plot on an FFTrees object.

plot.FFTrees visualizes a selected FFT, key data characteristics, and various aspects of classification performance.

As x may not contain test data, plot.FFTrees by default plots the performance characteristics for training data (i.e., fitting), rather than for test data (i.e., for prediction). When test data is available, specifying data = "test" plots prediction performance.

Whenever the sensitivity weight (sens.w) is set to its default of sens.w = 0.50, a level shows balanced accuracy (bacc). If, however, sens.w deviates from its default, the level shows the tree's weighted accuracy value (wacc) and the current sens.w value (below the level).

Many aspects of the plot (e.g., its panels) and the FFT's appearance (e.g., labels of its nodes and exits) can be customized by setting corresponding arguments.

Usage

# S3 method for FFTrees
plot(
  x = NULL,
  data = "train",
  what = "tree",
  tree = 1,
  main = NULL,
  cue.labels = NULL,
  decision.labels = NULL,
  cue.cex = NULL,
  threshold.cex = NULL,
  decision.cex = 1,
  comp = TRUE,
  stats = TRUE,
  show.header = NULL,
  show.tree = NULL,
  show.confusion = NULL,
  show.levels = NULL,
  show.roc = NULL,
  show.icons = NULL,
  show.iconguide = NULL,
  hlines = TRUE,
  label.tree = NULL,
  label.performance = NULL,
  n.per.icon = NULL,
  which.tree = NULL,
  level.type = "bar",
  decision.names = NULL,
  ...
)

Value

A plot visualizing and describing an FFT.

Arguments

x

An FFTrees object created by the FFTrees function.

data

The data in x to be plotted (as a string); must be either 'train' (for fitting performance) or 'test' (for prediction performance). By default, data = 'train' (as x may not contain test data).

what

What should be plotted (as a string)? 'tree' (the default) shows details of one tree (specified by tree); 'cues' shows the marginal accuracy of cues in ROC space; 'roc' shows the performance of tree(s) (and comparison algorithms) in ROC space.

tree

The tree to be plotted (as an integer, only valid when the corresponding tree argument is non-empty). Default: tree = 1. To plot the best training or best test tree with respect to the goal specified during FFT construction, use "best.train" or "best.test", respectively.

main

The main plot label (as a character string).

cue.labels

An optional string of labels for the cues / nodes (as character vector).

decision.labels

A character vector of length 2 indicating the content-specific names for noise and signal predictions/exits.

cue.cex

The size of the cue labels (as numeric).

threshold.cex

The size of the threshold labels (as numeric).

decision.cex

The size of the decision labels (as numeric).

comp

Should the performance of competitive algorithms (e.g.; logistic regression, random forests, etc.) be shown in the ROC plot (if available, as logical)?

stats

Should statistical information be plotted (as logical)? If FALSE, only the tree diagram (without any reference to statistics) will be plotted.

show.header

Show header with basic data properties (in top panel, as logical)?

show.tree

Show nodes and exits of FFT (in middle panel, as logical)?

show.confusion

Show 2x2 confusion matrix (in bottom panel, as logical)?

show.levels

Show performance levels (in bottom panel, as logical)?

show.roc

Show ROC curve (in bottom panel, as logical)?

show.icons

Show exit cases as icon arrays (in middle panel, as logical)?

show.iconguide

Show icon guide (in middle panel, as logical)?

hlines

Show horizontal panel separation lines (as logical)? Default: hlines = TRUE.

label.tree

Label for the FFT (optional, as character string).

label.performance

Labels for the performance section (optional, as character string).

n.per.icon

Number of cases per icon (as numeric).

which.tree

deprecated argument, included for backwards compatibility, use "tree" instead.

level.type

How should bottom levels be drawn (as a string)? Can be "bar" (the default) or "line".

decision.names

deprecated argument.

...

Graphical parameters (passed either to showcues when what = 'cues' or to title when what = 'roc').

See Also

showcues for plotting cue accuracies; print.FFTrees for printing FFTs; summary.FFTrees for summarizing FFTs; FFTrees for creating FFTs from and applying them to data.

Other plot functions: showcues()

Examples

Run this code
# Create FFTs (for heartdisease data):
heart.fft <- FFTrees(formula = diagnosis ~ .,
                     data = heartdisease
                     )

# Visualize the default FFT (Tree #1):
plot(heart.fft,
     main = "Heart Disease Diagnosis",
     decision.labels = c("Absent", "Present")
     )

# Visualize FFT #2 (with customized labels):
plot(heart.fft,
     tree = 2,
     main = "An FFT for heart disease diagnosis",
     cue.labels = c("1. thal?", "2. cp?", "3. ca?", "4. exang"),
     decision.labels = c("ok", "sick"),
     show.header = FALSE,
     show.confusion = FALSE,
     show.levels = FALSE,
     show.roc = FALSE
     )

# Visualize cue accuracies:
plot(heart.fft, what = "cues")

# For more details, see
vignette("FFTrees_plot", package = "FFTrees")

Run the code above in your browser using DataLab