Rsomoclu.kohonen | R Documentation |
A function call to convert Somoclu train result to kohonen class for plotting.
Rsomoclu.kohonen(input_data, result, n.hood = NULL, toroidal = FALSE)
input_data |
input data, matrix format |
result |
The result returned by Rsomoclu.train |
n.hood |
Same as in koohonen, the shape of the neighbourhood, either "circular" or "square". The latter is the default for rectangular maps, the former for hexagonal maps. |
toroidal |
if TRUE, the edges of the map are joined. Note that in a hexagonal toroidal map, the number of rows must be even. |
An object of class kohonen
for plotting.
https://www.r-bloggers.com/2014/02/self-organising-maps-for-customer-segmentation-using-r/
library('Rsomoclu') library('kohonen') data("rgbs", package = "Rsomoclu") input_data <- rgbs input_data <- data.matrix(input_data) nSomX <- 20 nSomY <- 20 nEpoch <- 10 radius0 <- 0 radiusN <- 0 radiusCooling <- "linear" scale0 <- 0 scaleN <- 0.01 scaleCooling <- "linear" kernelType <- 0 mapType <- "planar" gridType <- "rectangular" compactSupport <- FALSE codebook <- NULL neighborhood <- "gaussian" stdCoeff <- 0.5 res <- Rsomoclu.train(input_data, nEpoch, nSomX, nSomY, radius0, radiusN, radiusCooling, scale0, scaleN, scaleCooling, kernelType, mapType, gridType, compactSupport, neighborhood, stdCoeff, codebook) ## Convert to kohonen object for plotting sommap = Rsomoclu.kohonen(input_data, res) ## Show 'codebook' plot(sommap, type="codes", main = "Codes") ## Show 'component planes' plot(sommap, type = "property", property = sommap$codes[[1]][,1], main = colnames(sommap$codes)[1]) ## Show 'U-Matrix' plot(sommap, type="dist.neighbours")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.