Package mvpa :: Package mappers :: Module som :: Class SimpleSOMMapper
[hide private]
[frames] | no frames]

Class SimpleSOMMapper

source code


Mapper using a self-organizing map (SOM) for dimensionality reduction.

This mapper provides a simple, but pretty fast implementation of a self-organizing map using an unsupervised training algorithm. It performs a ND -> 2D mapping, which can for, example, be used for visualization of high-dimensional data.

This SOM implementation uses squared Euclidean distance to determine the best matching Kohonen unit and a Gaussian neighborhood influence kernel.

Instance Methods [hide private]
 
__init__(self, kshape, niter, learning_rate=0.005, iradius=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
train(self, ds)
Perform network training.
source code
 
_computeInfluenceKernel(self, iter, dqd)
Compute the neighborhood kernel for some iteration.
source code
 
_getBMU(self, sample)
Returns the ID of the best matching unit.
source code
 
forward(self, data)
Map data from the IN dataspace into OUT space.
source code
 
reverse(self, data)
Reverse map data from OUT space into the IN space.
source code
 
getInSize(self)
Returns the size of the entity in input space
source code
 
getOutSize(self)
Returns the size of the entity in output space
source code
 
selectOut(self, outIds)
Limit the OUT space to a certain set of features.
source code
 
getInId(self, outId)
Translate a feature id into a coordinate/index in input space.
source code
 
isValidOutId(self, outId)
Validate feature id in OUT space.
source code
 
__repr__(self)
repr(x)
source code
 
_accessKohonen(self)
Provide access to the Kohonen layer.
source code

Inherited from base.Mapper: __call__, getMetric, getNeighbor, getNeighborIn, getNeighbors, isValidInId, setMetric

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  K = property(fget= _accessKohonen)

Inherited from base.Mapper: metric, nfeatures

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, kshape, niter, learning_rate=0.005, iradius=None)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Parameters:
  • kshape, (int, int) - Shape of the internal Kohonen layer. Currently, only 2D Kohonen layers are supported, although the length of an axis might be set to 1.
  • niter, int - Number of iteration during network training.
  • learning_rate, float - Initial learning rate, which will continuously decreased during network training.
  • iradius, float, |, None - Initial radius of the Gaussian neighborhood kernel radius, which will continuously decreased during network training. If None (default) the radius is set equal to the longest edge of the Kohonen layer.
Overrides: object.__init__

train(self, ds)

source code 
Perform network training.
Overrides: base.Mapper.train

_computeInfluenceKernel(self, iter, dqd)

source code 
Compute the neighborhood kernel for some iteration.
Parameters:
  • iter, int - The iteration for which to compute the kernel.
  • dqd, array, (nrows, x, ncolumns) - This is one quadrant of Euclidean distances between Kohonen unit locations.

_getBMU(self, sample)

source code 

Returns the ID of the best matching unit.

'best' is determined as minimal squared Euclidean distance between any units weight vector and some given target sample

Parameters:
  • sample, array - Target sample.
Returns:
tuple: (row, column)

forward(self, data)

source code 

Map data from the IN dataspace into OUT space.

Mapping is performs by simple determining the best matching Kohonen unit for each data sample.

Overrides: base.Mapper.forward

reverse(self, data)

source code 
Reverse map data from OUT space into the IN space.
Overrides: base.Mapper.reverse

getInSize(self)

source code 
Returns the size of the entity in input space
Overrides: base.Mapper.getInSize

getOutSize(self)

source code 
Returns the size of the entity in output space
Overrides: base.Mapper.getOutSize

selectOut(self, outIds)

source code 

Limit the OUT space to a certain set of features.

This is currently not implemented. Moreover, although it is technically possible to implement this functionality, it is unsure whether it is meaningful in the context of SOMs.

Parameters:
  • outIds, sequence - Subset of ids of the current feature in OUT space to keep.
Overrides: base.Mapper.selectOut

getInId(self, outId)

source code 

Translate a feature id into a coordinate/index in input space.

This is not meaningful in the context of SOMs.

Overrides: base.Mapper.getInId

isValidOutId(self, outId)

source code 
Validate feature id in OUT space.
Overrides: base.Mapper.isValidOutId

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

_accessKohonen(self)

source code 

Provide access to the Kohonen layer.

With some care.