aweSOMscreeplot: Screeplot

Description Usage Arguments Examples

View source: R/plots.R

Description

Screeplot, helps deciding the optimal number of superclasses. Available for both PAM and hierarchical clustering.

Usage

1
2
3
4
5
6
7
aweSOMscreeplot(
  som,
  nclass = 2,
  method = c("hierarchical", "pam"),
  hmethod = c("complete", "ward.D2", "ward.D", "single", "average", "mcquitty",
    "median", "centroid")
)

Arguments

som

'kohonen' object, a SOM created by the 'kohonen::som' function.

nclass

number of superclasses to be visualized in the screeplot. Default is 2.

method

Method used for clustering. Hierarchical clustering ("hierarchical") and Partitioning around medoids ("pam") can be used. Default is hierarchical clustering.

hmethod

For hierarchicical clustering, the clustering method, by default "complete". See the stats::hclust documentation for more details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Build training data
dat <- iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
### Scale training data
dat <- scale(dat)
## Train SOM
### Initialization (PCA grid)
init <- somInit(dat, 4, 4)
ok.som <- kohonen::som(dat, grid = kohonen::somgrid(4, 4, 'hexagonal'),
                       rlen = 100, alpha = c(0.05, 0.01),
                       radius = c(6.08,-6.08),
                       init = init, dist.fcts = 'sumofsquares')
## Group cells into superclasses (PAM clustering)
superclust <- cluster::pam(ok.som$codes[[1]], 2)
superclasses <- superclust$clustering
aweSOMscreeplot(ok.som, method = 'hierarchical',
                hmethod = 'complete', nclass = 2)

jansodoge/awesom_dev_version documentation built on Jan. 26, 2021, 8:53 a.m.