classmap: Draw the class map to visualize classification results.

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

View source: R/VCR_visualization.R

Description

Draw the class map to visualize classification results, based on the output of one of the vcr.*.* functions in this package. The vertical axis of the class map shows each case's PAC, the conditional probability that it belongs to an alternative class. The farness on the horizontal axis is the probability of a member of the given class being at most as far from the class as the case itself.

Usage

1
2
3
4
classmap(vcrout, whichclass, classLabels = NULL, classCols = NULL,
         main = NULL, cutoff = 0.99, plotcutoff = TRUE, identify = FALSE,
         cex = 1, cex.main=1.2, cex.lab=NULL, cex.axis=NULL, opacity = 1,
         squareplot = TRUE,  maxprob = NULL, maxfactor=NULL)

Arguments

vcrout

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

whichclass

the number or level of the class to be displayed. Required.

classLabels

the labels (levels) of the classes. If NULL, they are taken from vcrout.

classCols

a list of colors for the class labels. There should be at least as many as there are levels. If NULL the classCols are taken as 2, 3, 4, ...

main

title for the plot.

cutoff

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

plotcutoff

If true, plots the cutoff on the farness values as a vertical line.

identify

if TRUE, invoke graphics::identify after plotting: left-click on a point to get its number, then ESC to exit.

cex

passed on to graphics::plot.

cex.main

same, for title.

cex.lab

same, for labels on horizontal and vertical axes.

cex.axis

same, for axes.

opacity

determines opacity of plotted dots. Value between 0 and 1, where 0 is transparent and 1 is opaque.

squareplot

If TRUE, makes the axes of the plot equally long.

maxprob

draws the farness axis at least upto probability maxprob. If NULL, the limits are obtained automatically.

maxfactor

if not NULL, a number slightly higher than 1 to increase the space at the right hand side of the plot, to make room for marking points.

Value

Executing the function plots the class map and returns

coordinates

a matrix with 2 columns containing the coordinates of the plotted points. The first coordinate is the quantile of the farness probability. This makes it easier to add text next to interesting points. If identify = T, the attribute ids of coordinates contains the row numbers of the identified points in the matrix coordinates.

Author(s)

Raymaekers J., Rousseeuw P.J.

References

Raymaekers J., Rousseeuw P.J., Hubert M. (2021). Class maps for visualizing classification results. Technometrics, forthcoming. (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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
vcrout = vcr.da.train(iris[,1:4], iris[,5])
classmap(vcrout, "setosa", classCols = 2:4) # tight class
classmap(vcrout, "versicolor", classCols = 2:4) # less tight
# The cases misclassified as virginica are shown in blue.
classmap(vcrout, "virginica", classCols = 2:4)
# The case misclassified as versicolor is shown in green.

# For more examples, we refer to the vignettes:
vignette("Discriminant_analysis_examples")
vignette("K_nearest_neighbors_examples")
vignette("Support_vector_machine_examples")

classmap documentation built on May 10, 2021, 9:10 a.m.