Package mvpa :: Package mappers :: Module pca :: Class PCAMapper
[hide private]
[frames] | no frames]

Class PCAMapper

source code


Mapper to project data onto PCA components estimated from some dataset.

After the mapper has been instantiated, it has to be train first. When train() is called with a 2D (samples x features) matrix the PCA components are determined by performing singular value decomposition on the covariance matrix.

The PCA mapper only handle 2D data matrices.

Constructor information for PCAMapper class

Initialize the PCAMapper

Documentation for base classes of PCAMapper

Documentation for class Mapper

Interface to provide mapping between two spaces: in and out.

Methods are prefixed correspondingly. forward/reverse operate on the entire dataset. get(In|Out)Id[s] operate per element:

      forward
in   ---------> out
     <--------/
       reverse

Subclasses should define 'dsshape' and 'nfeatures' properties that point to getInShape and getOutSize respectively. This cannot be done in the baseclass as standard Python properties would still point to the baseclass methods.

Constructor information for Mapper class

Does nothing.

Instance Methods [hide private]
 
__init__(self, selector=None)
Initialize the PCAMapper
source code
 
__deepcopy__(self, memo=None)
Yes, this is it.
source code
 
train(self, dataset)
Determine the projection matrix onto the PCA components from a 2D samples x feature data matrix.
source code
 
forward(self, data)
Project a 2D samples x features matrix onto the PCA components.
source code
 
reverse(self, data)
Projects feature vectors or matrices with feature vectors back onto the original features.
source code
 
getInShape(self)
Returns a one-tuple with the number of original features.
source code
 
getOutShape(self)
Returns a one-tuple with the number of PCA components.
source code
 
getInSize(self)
Returns the number of original features.
source code
 
getOutSize(self)
Returns the number of PCA components.
source code
 
selectOut(self, outIds)
Choose a subset of PCA components (and remove all others).
source code

Inherited from base.Mapper: __call__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  __doc__ = enhancedDocString('PCAMapper', locals(), Mapper)

Inherited from base.Mapper: nfeatures

Instance Variables [hide private]
  mix
Transformation matrix from orginal features onto PCA-components.
  unmix
Un-mixing matrix for projecting from the PCA space back onto the original features.
  sv
Eigenvalues of the covariance matrix.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, selector=None)
(Constructor)

source code 
Initialize the PCAMapper
Parameters:
  • selector, None, list, of, ElementSelector - Which PCA components should be used for mapping. If selector is None all components are used. If a list is provided, all list elements are treated as component ids and the respective components are selected (all others are discarded). Alternatively an ElementSelector instance can be provided which chooses components based on the corresponding eigenvalues of each component.
  • selector, None, list, of, ElementSelector - Which PCA components should be used for mapping. If selector is None all components are used. If a list is provided, all list elements are treated as component ids and the respective components are selected (all others are discarded). Alternatively an ElementSelector instance can be provided which chooses components based on the corresponding eigenvalues of each component.
Overrides: object.__init__

train(self, dataset)

source code 
Determine the projection matrix onto the PCA components from a 2D samples x feature data matrix.
Overrides: base.Mapper.train

forward(self, data)

source code 
Project a 2D samples x features matrix onto the PCA components.
Returns:
NumPy array
Overrides: base.Mapper.forward

reverse(self, data)

source code 
Projects feature vectors or matrices with feature vectors back onto the original features.
Returns:
NumPy array
Overrides: base.Mapper.reverse

getInShape(self)

source code 
Returns a one-tuple with the number of original features.
Overrides: base.Mapper.getInShape

getOutShape(self)

source code 
Returns a one-tuple with the number of PCA components.
Overrides: base.Mapper.getOutShape

getInSize(self)

source code 
Returns the number of original features.
Overrides: base.Mapper.getInSize

getOutSize(self)

source code 
Returns the number of PCA components.
Overrides: base.Mapper.getOutSize

selectOut(self, outIds)

source code 
Choose a subset of PCA components (and remove all others).
Overrides: base.Mapper.selectOut