Package mvpa :: Package mappers :: Module svd :: Class SVDMapper
[hide private]
[frames] | no frames]

Class SVDMapper

source code


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

Constructor information for SVDMapper class

Initialize the SVDMapper

Documentation for base classes of SVDMapper

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, demean=True)
Initialize the SVDMapper
source code
 
__deepcopy__(self, memo=None)
Yes, this is it.
source code
 
train(self, dataset)
Determine the projection matrix onto the SVD components from a 2D samples x feature data matrix.
source code
 
forward(self, data, demean=True)
Project a 2D samples x features matrix onto the SVD 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 SVD components.
source code
 
getInSize(self)
Returns the number of original features.
source code
 
getOutSize(self)
Returns the number of SVD components.
source code
 
selectOut(self, outIds)
Choose a subset of SVD 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('SVDMapper', locals(), Mapper)

Inherited from base.Mapper: nfeatures

Instance Variables [hide private]
  mix
Transformation matrix from orginal features onto SVD-components.
  unmix
Un-mixing matrix for projecting from the SVD space back onto the original features.
  sv
Singular values of the training matrix.
  mean
Data mean
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, selector=None, demean=True)
(Constructor)

source code 
Initialize the SVDMapper
Parameters:
  • selector, None, list, of, ElementSelector - Which SVD 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.
  • demean, bool - Either data should be demeaned while computing projections and applied back while doing reverse()
  • selector, None, list, of, ElementSelector - Which SVD 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.
  • demean, bool - Either data should be demeaned while computing projections and applied back while doing reverse()
Overrides: object.__init__

__deepcopy__(self, memo=None)

source code 
Yes, this is it. XXX But do we need it really? copy.deepcopy wouldn't have a problem copying stuff

train(self, dataset)

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

forward(self, data, demean=True)

source code 
Project a 2D samples x features matrix onto the SVD components.

:Parameters:
    data: array
        Data arry to map
    demean: bool
        Flag whether to substract the training data mean before mapping.
        XXX: Not sure if this is the right place. Maybe better move to
             constructor as it would be difficult to set this flag.
: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 SVD 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 SVD components.
Overrides: base.Mapper.getOutSize

selectOut(self, outIds)

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