plot,SOMnn,ANY-method {som.nn} | R Documentation |
Plot method for S4 class SOMnn
Description
Creates a plot of the hexagonal som in the model of type SOMnn
.
Usage
## S4 method for signature 'SOMnn,ANY'
plot(
x,
title = TRUE,
col = NA,
onlyDefCols = FALSE,
edit.cols = FALSE,
show.legend = TRUE,
legend.loc = "bottomright",
legend.width = 4,
window.width = NA,
window.height = NA,
show.box = TRUE,
show.counter.border = 0.98,
predict = NULL,
add = FALSE,
pch.col = "black",
pch = 19,
...
)
Arguments
x |
trained som of type |
title |
|
col |
defines colours for the classes of the dataset. Possible values include:
|
onlyDefCols |
|
edit.cols |
|
show.legend |
|
legend.loc |
Legend position as specified for |
legend.width |
size of the legend. |
window.width |
Manual setting of window width. Default is NA. |
window.height |
Manual setting of window height. Default is NA. |
show.box |
Show frame around the plot . Default is TRUE. |
show.counter.border |
Percentile as limit for the display of labels in the pie charts. Default is 0.98. Higher counts are displayed as numbers in the neuron. |
predict |
|
add |
|
pch.col |
Colour of the markers for predicted samples. |
pch |
Symbol of the markers for predicted samples. |
... |
More parameters as well as general
plot parameters are allowed; see |
Details
In addition to the required parameters, many options can be specified to plot predicted samples and to modify colours, legend and scaling.
Examples
## get example data and add class labels:
data(iris)
species <- iris$Species
## train with default radius = diagonal / 2:
rlen <- 500
som <- som.nn.train(iris, class.col = "Species", kernel = "internal",
xdim = 15, ydim = 9, alpha = 0.2, len = rlen,
norm = TRUE, toroidal = FALSE)
## continue training with different alpha and radius;
som <- som.nn.continue(som, iris, alpha = 0.02, len=500, radius = 5)
som <- som.nn.continue(som, iris, alpha = 0.02, len=500, radius = 2)
## predict some samples:
unk <- iris[,!(names(iris) %in% "Species")]
setosa <- unk[species=="setosa",]
setosa <- setosa[sample(nrow(setosa), 20),]
versicolor <- unk[species=="versicolor",]
versicolor <- versicolor[sample(nrow(versicolor), 20),]
virginica <- unk[species=="virginica",]
virginica <- virginica[sample(nrow(virginica), 20),]
p <- predict(som, unk)
head(p)
## plot:
plot(som)
dev.off()
plot(som, predict = predict(som, setosa))
plot(som, predict = predict(som, versicolor), add = TRUE, pch.col = "magenta", pch = 17)
plot(som, predict = predict(som, virginica), add = TRUE, pch.col = "white", pch = 8)