Learn R Programming

GrowingSOM (version 0.1.1)

train_xy.gsom: Train a supervised Growing Self-Organizing Map

Description

Computes a supervised growing self-organizing map for mapping high-dimendional data to 2D.

Usage

train_xy.gsom(data, y, spreadFactor=0.8, keepdata=FALSE, iterations=50, alpha=0.9, beta = 0.5, gridsize = FALSE, nhood= "rect", initrad = NULL, ...)

Arguments

data
a matrix or data.frame, with each row representing an observation and each column a dimension.
y
a matrix or data.frame, with each row representing an observation and each column a y-dimension.
spreadFactor
the spread factor determines the rate with which new units are added to the map. Values close to 0 lead to few growth and therefore less nodes thatn values close to 1. The default value is 0.9.
keepdata
if set to TRUE, a copy of the traindata will be stored in the gsom object.
iterations
number of times that the dataframe will be presented to the network. (Growing and Smoothing Phase combined)
alpha
discount factor for the learning rate during the growing phase of the training. Values should be between 0 and 1.
beta
propagation rate. Determines the rate at which the error of a node, that cannot grow any nodes, is passed on to its neighbours. Suggested values may range between 0 and 1.
gridsize
default value is FALSE. If a nummeric value is entered, the grid-size of the network will be preditermined as a square with length of gridsize. No growth of the network will take place in this case and the values for alpha and beta will be ignored.
nhood
define how the grid will be built, and how the neighbourhood will look like consequently. Allowed values are "rect" (rectangular) and "hex" (hexagonal).
initrad
if the gridsize is predetermined, the initial radius can be chosen here. If left blank, the square root of gridsize will be taken. A larger initrad can increase the quality of the clustering. However, the script can get very slow when a too large value is chosen. (number of necessary computations rises exponentially)
...
not used.

Value

an S3 object of class "gsom" with components:

Details

Euclidean distance is used in order to calculate the distances.

References

Damminda Alahakoon, Saman K. Halgamuge (2000): Dynamic Self-Organizing Maps with Controlled Growth for Knowledge Discovery. IEEE TRANSACTIONS ON NEURAL NETWORKS, VOL. 11.

See Also

train.gsom, predict.gsom, plot.gsom

Examples

Run this code

  # load data
  data("auto_mpg")
  s = sample(1:392, 300)
  train_set = auto_mpg[s,1:8]

  # Train Gsom Model
  gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9)

  # Fixed Grid size
  gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], gridsize = 6)

  # Train Gsom Model (hexagonal grid)
  gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9, nhood="hex")

  # Plot Predicted values for each node
  plot(gsom_object)
  par(mfrow=c(2,2))
  plot(gsom_object, type = "property")
  par(mfrow=c(1,1))
  plot(gsom_object, type = "predict")

Run the code above in your browser using DataLab