SOM — CPU Implementation
The SOM class is the core NumPy-based Self-Organizing Map.
All public symbols are importable directly from NNSOM:
from NNSOM.som import SOM
som = SOM((8, 8))
som.init_w(data)
som.train(data, init_neighborhood=3, epochs=200, steps=100)
- class NNSOM.som.SOM(dimensions)[source]
Bases:
objectA class to represent a Self-Organizing Map (SOM), a type of artificial neural network trained using unsupervised learning to produce a two-dimensional, discretized representation of the input space of the training samples.
- dimensions
The dimensions of the SOM grid. Determines the layout and number of neurons in the map.
- numNeurons
The total number of neurons in the SOM, calculated as the product of the dimensions.
- Type:
- pos
The positions of the neurons in the SOM grid.
- Type:
array-like
- neuron_dist
The distances between neurons in the SOM.
- Type:
array-like
- w
The weight matrix of the SOM, representing the feature vectors of the neurons.
- Type:
array-like
- __init__(self, dimensions):
Initializes the SOM with the specified dimensions.
- init_w(self, x):
Initializes the weights of the SOM using principal components analysis on the input data x.
- sim_som(self, x):
Simulates the SOM with x as the input, determining which neurons are activated by the input vectors.
- train(self, x, init_neighborhood=3, epochs=200, steps=100):
Trains the SOM using the batch SOM algorithm on the input data x.
- save_pickle(self, filename, path, data_format='pkl'):
Saves the SOM object to a file using the pickle format.
- load_pickle(self, filename, path, data_format='pkl'):
Loads a SOM object from a file using the pickle format.
Initialization and training
Initializes the weights of the SOM using principal components analysis (PCA) on the input data x. |
|
Trains the SOM using the batch SOM algorithm on the input data x. |
|
Simulates the SOM with x as the input, determining which neurons are activated by the input vectors. |
Clustering
Cluster the input data based on the trained SOM reference vectors. |
Quality metrics
Calculate quantization error |
|
Calculate topological error |
|
Calculate distortion |
Persistence
Save the SOM object to a file using pickle. |
|
Load the SOM object from a file using pickle. |