nroTrain | R Documentation |
Iterative algorithm to adapt a self-organizing map (SOM) to a set of multivariable data.
nroTrain(map, data, subsample = NULL, balance = 0, message = NULL)
map |
A list object as returned by |
data |
A matrix or a data frame. |
subsample |
Number of rows used during a single training cycle. |
balance |
Penalty parameter for variation in the numbers of resident
samples across disctricts, see |
message |
If positive, progress information is printed at the specified interval in seconds. |
The map is fitted according to columns that are found both in the SOM centroids and the input data.
If subsample
is less than the number of data rows, a random subset of
the specified size is used for each training cycle. By default,
subsample
is set automatically depending on the size of the dataset.
A copy of the list object map
, where the element centroids
is
updated according to the data patterns. The quantization errors during
training are stored in the element history
. The subsampling
parameter that was used during training is stored in the element
subsample
.
# Import data.
fname <- system.file("extdata", "finndiane.txt", package = "Numero")
dataset <- read.delim(file = fname)
# Prepare training data.
trvars <- c("CHOL", "HDL2C", "TG", "CREAT", "uALB")
trdata <- scale.default(dataset[,trvars])
# K-means clustering.
km <- nroKmeans(data = trdata)
# Train with full data.
sm <- nroKohonen(seeds = km)
sm <- nroTrain(map = sm, data = trdata, subsample = nrow(trdata))
print(sm$history)
# Train with subsampling.
sm <- nroKohonen(seeds = km)
sm <- nroTrain(map = sm, data = trdata, subsample = 200)
print(sm$history)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.