Interface to Self Organizing Maps algorithm. For implementation of SOM, Orange integrates a SOM_PAK package from the inventors of the method.
SOMLearner
SOMLearner is a function that constructs an instance of SOMLearner instance. If an optional data set is provided, a corresponding Self Organizing Map will be constructed (training).
Arguments
- examples
- Data instances to be used for training (default None).
- wightID
- Index of the meta attribute that contains weight values (default 0, no weights).
- xDim
- X dimension of the map (default 10).
- yDim
- Y dimension of the map (default 10).
- topology
- Topology of the map. Can be a SOMLearner.RetangularTopology for rectangular or SOMLearner.HexagonalTopology (default) for hexagonal topology.
- neighborhood
-
- Neighborhood function type. Can be SOMLearner.BubbleNeighborhood (default) or SOMLearner.GaussianNeighborhood.
- alphaType
- An alpha function type. Can be a SOMLearner.LinearFunction (default) or SOMLearner.InverseFunction.
- randomSeed
- Random seed used to initialize the codebook vectors. Use -1 to use current time as a seed (default 0).
- parameters
- Specifies the radius, alpha and number of iterations for each
phase of training. The parameters are passed as a list of dictionaries
(e.g. parameters=[{"iterations":1000, "radius":5.0, "alpha":0.05},
{"iterations":10000, "radius":3.0, "alpha":0.02}]. Notice that not all
(or even any) items in a dictionary are mandatory. For instance, {"iterations:1000}
is a valid item in the
parameters
list, in which case the last given value (or the default in the case of none) will be used for other parameters.
getUMatrix
A function that constructs a u-matrix (uniform distance matrix) for the Self-Organizing learner somMap
which is passed as an argument. The construction of the matrix depends on the topology of the SOM.
Arguments
- somMap
- SOM for which the u-matrix is to be constructed
Examples
As an example we are going to train the SOM on the iris dataset and then print the nodes and the examples associated with that node. Notice that clas-values are not used when constructing SOM.
l=orngSOM.SOMLearner(xDim=5, yDim=10, parameters=[{"iterations":1000, "radius":5, "alpha":0.05},{"iterations":10000, "alpha":0.02}])
c=l(orange.ExampleTable("iris.tab"))
for n in c.nodes:
print "node:", n.x,n.y
for e in n.examples:
print "\t",e
With the result
node: 0 0
[7.2, 3.6, 6.1, 2.5, 'Iris-virginica']
[7.7, 3.8, 6.7, 2.2, 'Iris-virginica']
[7.9, 3.8, 6.4, 2.0, 'Iris-virginica']
node: 1 0
[7.2, 3.2, 6.0, 1.8, 'Iris-virginica']
[7.7, 3.0, 6.1, 2.3, 'Iris-virginica']
node: 2 0
[7.1, 3.0, 5.9, 2.1, 'Iris-virginica']
[7.6, 3.0, 6.6, 2.1, 'Iris-virginica']
[7.3, 2.9, 6.3, 1.8, 'Iris-virginica']
[7.7, 2.6, 6.9, 2.3, 'Iris-virginica']
[7.7, 2.8, 6.7, 2.0, 'Iris-virginica']
...