orngSOM
orngSOM module contains an implementation of the Self Organizing Map (also known as Kohonen map) algorithm
SOMLearner
SOMLearner is a class used to train the SOM on the training data
Arguments
- map_shape
- A tuple containing the width and height of the map (default (5, 10))
- initialize
- Specifies one of the two ways the map is initialized, InitializeLinear (default) or InitializeRandom
- neighbourhood
- Specifies one of the two map neighbourhood types, NeighbourhoodGaussian (default) or NeighbourhoodBubble
- topology
- Specifies one of the two map topology types, HexagonalTopology (default) or RectangularTopology
- radius_ini
- The start radius (default 3)
- radius_fin
- The final radius (default 1)
- epochs
- The number of training iterations
SOMSupervisedLearner
SOMSupervisedLearner is a class used to learn SOM from orange.ExampleTable, by using the
class information in the learning process. This is achieved by adding a value for each class
to the training instances, where 1.0 signals class membership and all other values are 0.0.
After the training, the new values are discarded from the node vectors. Otherwise it behaves
just like the SOMLearner.
SOMMap
SOMMap contains the resulting trained map
Methods
- getBestMatchingNode(example)
- Return the node closest to the example
- __call__(example)
- Predict the class of the example by finding the best matching node of the example and classify
it to the majority class of all training instances mapped to this node (only works if the class information
is present in the learning data)
- __getitem__(i, j)
- Return the node in the i-th row and i-th column (e.g. map[1, 3])
- __iter__()
- Return an iterator over all the nodes
Example
>>> som = orngSOM.SOMLearner(map_shape=(10, 20), initialize=orngSOM.InitializeRandom)
>>> map = som(orange.ExampleTable("iris.tab"))
>>> for n in map:
>>> print "node:", n.pos[0], n.pos[1]
>>> for e in n.examples:
>>> print "\t",e