silplot: Draw the silhouette plot of a classification

View source: R/VCR_visualization.R

silplotR Documentation

Draw the silhouette plot of a classification

Description

Draw the silhouette plot to visualize classification results, based on the output of one of the vcr.*.* functions in this package. The horizontal axis of the silhouette plot shows each case's s(i).

Usage

silplot(vcrout, classLabels = NULL, classCols = NULL,
        showLegend = TRUE, showClassNumbers = FALSE,
        showCases = FALSE, drawLineAtAverage = FALSE,
        topdown = TRUE, main = NULL, summary = TRUE)

Arguments

vcrout

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

classLabels

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

classCols

a list of colors for the classes. There should be at least as many as there are levels. If NULL a default palette is used.

showLegend

if TRUE, a legend is shown to the right of the plot.

showClassNumbers

if TRUE, the legend will show the class numbers instead of the class labels.

showCases

if TRUE, the plot shows the numbers of the cases. They are only readable when the number of cases is relatively small.

topdown

if TRUE (the default), the silhouettes are plotted from top to bottom. Otherwise they are plotted from left to right.

drawLineAtAverage

if TRUE, drwas a line at the average value of the s(i).

main

title for the plot. If NULL, a default title is used.

summary

if TRUE, puts a summary table on the screen with for each class its number, label, number of class members, and the average of its s(i).

Value

A ggplot object containing the silhouette plot.

Author(s)

Raymaekers J., Rousseeuw P.J.

References

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])
silplot(vcrout)
# 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("Forest_examples")
vignette("Neural_net_examples")

## End(Not run)

classmap documentation built on April 23, 2023, 5:09 p.m.