stackedplot: Make a vertically stacked mosaic plot of class predictions.

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/VCR_visualization.R

Description

Make a vertically stacked mosaic plot of class predictions from the output of vcr.*.train or vcr.*.newdata. Optionally, the outliers for each class can be shown as a gray rectangle at the top.

Usage

1
2
3
4
stackedplot(vcrout, cutoff = 0.99, classCols = NULL,
classLabels = NULL, separSize=1, minSize=1.5,
showOutliers = TRUE, showLegend = FALSE, main = NULL,
htitle = NULL, vtitle = NULL)

Arguments

vcrout

output of vcr.*.train or vcr.*.newdata.

cutoff

cases with overall farness vcrout$ofarness > cutoff are flagged as outliers.

classCols

user-specified colors for the classes. If NULL a default palette is used.

classLabels

names of given labels. If NULL they are taken from vcrout.

separSize

how much white between rectangles.

minSize

rectangles describing less than minSize percent of the data, are shown as minSize percent.

showOutliers

if TRUE, shows a separate class in gray with the outliers, always at the top.

showLegend

if TRUE, a legend is shown to the right of the plot. Default FALSE, since the legend is not necessary as the colors are already visible in the bottom part of each stack.

main

title for the plot.

htitle

title for horizontal axis (given labels). If NULL, a default title is shown.

vtitle

title for vertical axis (predicted labels). If NULL, a default title is shown.

Value

A ggplot object.

Author(s)

Raymaekers J., Rousseeuw P.J.

References

Raymaekers J., Rousseeuw P.J., Hubert M. (2021). Class maps for visualizing classification results. Technometrics, appeared online. doi: 10.1080/00401706.2021.1927849(link to open access pdf)

See Also

vcr.da.train, vcr.da.newdata,
vcr.knn.train, vcr.knn.newdata,
vcr.svm.train, vcr.svm.newdata,
vcr.rpart.train, vcr.rpart.newdata,
vcr.forest.train, vcr.forest.newdata,
vcr.neural.train, vcr.neural.newdata

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
data("data_floralbuds")
X <- data_floralbuds[, 1:6]; y <- data_floralbuds[, 7]
vcrout <- vcr.da.train(X, y)
cols <- c("saddlebrown", "orange", "olivedrab4", "royalblue3")
stackedplot(vcrout, classCols = cols, showLegend = TRUE)

# The legend is not really needed, since we can read the
# color of a class from the bottom of its vertical bar:
stackedplot(vcrout, classCols = cols, main = "Stacked plot of QDA on foral buds data")

# If we do not wish to show outliers:
stackedplot(vcrout, classCols = cols, showOutliers = FALSE)

# For more examples, we refer to the vignettes:
## Not run: 
vignette("Discriminant_analysis_examples")
vignette("K_nearest_neighbors_examples")
vignette("Support_vector_machine_examples")
vignette("Rpart_examples")
vignette("Random_forest_examples")
vignette("Neural_net_examples")

## End(Not run)

classmap documentation built on Jan. 10, 2022, 1:06 a.m.