Package com.imsl.datamining
Class KohonenSOMTrainer
java.lang.Object
com.imsl.datamining.KohonenSOMTrainer
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
KohonenSOMEx1
Trains a Kohonen network.
KohonenSOMTrainer is an abstract class with 2 abstract
methods, getNeighborhoodValue and
getLearningCoefficient. Therefore, a subclass
of KohonenSOMTrainer needs to implement the
getNeighborhoodValue and getLearningCoefficient
methods.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of iterations used for training.abstract doublegetLearningCoefficient(int t) Returns the learning coefficient.abstract doublegetNeighborhoodValue(int t, double d) Returns the neighborhood function value.intReturns the number ofjava.lang.Threadinstances used for parallel processing.voidsetIterations(int iterations) Sets the number of iterations to be used for training.voidsetNumberOfThreads(int numberOfThreads) Sets the number ofjava.lang.Threadinstances to be used for parallel processing.final voidtrain(KohonenSOM kohonen, double[][] data) Trains a Kohonen network.
-
Constructor Details
-
KohonenSOMTrainer
public KohonenSOMTrainer()
-
-
Method Details
-
getNeighborhoodValue
public abstract double getNeighborhoodValue(int t, double d) Returns the neighborhood function value. In the simplest form, the neighborhood function \(h\left( {d,t} \right)\) is 1 for all nodes closest to the BMU and 0 for others, but a Gaussian function is also commonly used. For example:\(h\left( {d,t} \right) = \exp(-d^2/2r^2)\) where r represents the neighborhood radius at index t
- Parameters:
t- Anintscalar containing the current iteration of the training.d- Adoublescalar containing the lattice distance between the best matching node and the current node.- Returns:
- A
doublescalar containing the computed neighborhood function value.
-
getLearningCoefficient
public abstract double getLearningCoefficient(int t) Returns the learning coefficient. The monotonically decreasing learning coefficient function \(\alpha \left( t \right)\) is a scalar factor that defines the size of the update correction. The value of \(\alpha \left( t \right)\) decreases with the step indext. Typical forms are linear, power, and inverse time/step. For example:power:
$$\alpha \left( t \right) = \alpha_{0} \left( \frac{\alpha_{T}}{\alpha_{0}} \right)^{t/T}$$where t=
t, T=the number of iterations used for training, \(\alpha_{0}\) = initial learning coefficient, \(\alpha_{T}\) = final learning coefficientinverse time:
$$\alpha \left( t \right) = \frac{A}{t+B}$$where A and B are user determined constants
- Parameters:
t- Anintscalar containing the current iteration of the training.- Returns:
- A
doublescalar containing the computed learning coefficient.
-
setNumberOfThreads
public void setNumberOfThreads(int numberOfThreads) Sets the number ofjava.lang.Threadinstances to be used for parallel processing.- Parameters:
numberOfThreads- anintspecifying the number ofjava.lang.Threadinstances to be used for parallel processing.Default:
numberOfThreads= 1.
-
getNumberOfThreads
public int getNumberOfThreads()Returns the number ofjava.lang.Threadinstances used for parallel processing.- Returns:
- an
intcontaining the number ofjava.lang.Threadinstances used for parallel processing.
-
setIterations
public void setIterations(int iterations) Sets the number of iterations to be used for training.- Parameters:
iterations- Anintscalar containing the number of iterations to be used for training.iterationsmust be greater than zero.Default:
iterations= 100.
-
getIterations
public int getIterations()Returns the number of iterations used for training.- Returns:
- An
intscalar containing the number of iterations used for training.
-
train
Trains a Kohonen network.- Parameters:
kohonen- AKohonenSOMobject to be trained.data- Adoublematrix containing the data to be used for training the Kohonen network.data[i].lengthmust be equal todim, the number of weights for each node, inkohonen.
-