classmap: Draw the class map to visualize classification results.

View source: R/VCR_visualization.R

classmapR Documentation

Draw the class map to visualize classification results.

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

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, 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, appeared online. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00401706.2021.1927849")}(link to open access pdf)

Raymaekers J., Rousseeuw P.J.(2021). Silhouettes and quasi residual plots for neural nets and tree-based classifiers. (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

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:
## 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 April 23, 2023, 5:09 p.m.