plot-methods: Plot method for S4 class 'SOMnn'

Description Usage Arguments Details Examples

Description

Creates a plot of the hexagonal som in the model of type SOMnn.

Usage

1
2
3
4
5
6
## 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 SOMnn.

title

logical; if TRUE, slots name and date are used as main title.

col

defines colours for the classes of the dataset. Possible values include: NA: default value; colours are generated with rainbow, a vector of colour definitions or a data.frame with categories in the first and respective colours in the second column.

onlyDefCols

logical; if TRUE, only categories are plotted, for which colours are defined. Default: FALSE.

edit.cols

logical; if TRUE, colour definitions can be edited interactively before plotting. Default: FALSE.

show.legend

logical; if TRUE, a legend is displayed,. Default: TRUE.

legend.loc

Legend position as specified for legend. Default is "bottomright".

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

data.frame as returned by the som.nn::predict function or a data.frame or matrix that follows the specification: If columns x and y exist, these are used as coordinates for the traget neuron; otherwise the first two columns are used. Default: NULL.

add

logical; if TRUE, points are plotted on an existing plot. This can be used to stepwise plot points of different classes with different colours or symbols.

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 par.

Details

In addition to the required parameters, many options can be specified to plot predicted samples and to modify colours, legend and scaling.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## get example data and add class labels:
data(iris)
species <- iris$Species

## train with default radius = diagonal / 2:
som <- som.nn.train(iris, class.col = "Species", kernel = "internal",
                    xdim = 15, ydim = 9, alpha = 0.2, len = 10000, 
                    norm = TRUE, toroidal = FALSE)


## continue training with different alpha and radius;
som <- som.nn.continue(som, iris, alpha = 0.02, len=1000, radius = 5)
som <- som.nn.continue(som, iris, alpha = 0.02, len=1000, 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 = som@predict(setosa))
plot(som, predict = som@predict(versicolor), add = TRUE, pch.col = "magenta", pch = 17)
plot(som, predict = som@predict(virginica), add = TRUE, pch.col = "white", pch = 8)

som.nn documentation built on May 2, 2019, 8:26 a.m.