Package mvpa :: Package mappers :: Module base :: Class ProjectionMapper
[hide private]
[frames] | no frames]

Class ProjectionMapper

source code


Linear mapping between multidimensional spaces.

This class cannot be used directly. Sub-classes have to implement the _train() method, which has to compute the projection matrix _proj and optionally offset vectors _offset_in and _offset_out (if initialized with demean=True, which is default) given a dataset (see _train() docstring for more information).

Once the projection matrix is available, this class provides functionality to perform forward and backwards linear mapping of data, the latter by default using pseudo-inverse (but could be altered in subclasses, like hermitian (conjugate) transpose in case of SVD). Additionally, ProjectionMapper supports optional selection of arbitrary component (i.e. columns of the projection matrix) of the projection.

Forward and back-projection matrices (a.k.a. projection and reconstruction) are available via the proj and recon properties.

Instance Methods [hide private]
 
__init__(self, selector=None, demean=True)
Initialize the ProjectionMapper
source code
 
train(self, dataset, *args, **kwargs)
Determine the projection matrix.
source code
 
_demeanData(self, data)
Helper which optionally demeans
source code
 
_train(self, dataset)
Worker method. Needs to be implemented by subclass.
source code
 
forward(self, data, demean=None)
Perform forward projection.
source code
 
reverse(self, data)
Reproject (reconstruct) data into the original feature space.
source code
 
_computeRecon(self)
Given that a projection is present -- compute reconstruction matrix. By default -- pseudoinverse of projection matrix. Might be overridden in derived classes for efficiency.
source code
 
_getRecon(self)
Compute (if necessary) and return reconstruction matrix
source code
 
getInSize(self)
Returns the number of original features.
source code
 
getOutSize(self)
Returns the number of components to project on.
source code
 
selectOut(self, outIds)
Choose a subset of components (and remove all others).
source code

Inherited from Mapper: __call__, __repr__, getInId, getMetric, getNeighbor, getNeighborIn, getNeighbors, isValidInId, isValidOutId, setMetric

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

Class Variables [hide private]
  _DEV__doc__ = """Think about renaming `demean`, may be `transl...
  __doc__ = enhancedDocString('ProjectionMapper', locals(), Mapper)
  proj = property(fget= lambda self: self._proj, doc= "Projectio...
  recon = property(fget= _getRecon, doc= "Backprojection matrix")

Inherited from Mapper: metric, nfeatures

Instance Variables [hide private]
  _proj
Forward projection matrix.
  _recon
Reverse projection (reconstruction) matrix.
  _demean
Flag whether to demean the to be projected data, prior to projection.
  _offset_in
Offset (most often just mean) in the input space
  _offset_out
Offset (most often just mean) in the output space
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

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

train(self, dataset, *args, **kwargs)

source code 
Determine the projection matrix.
Overrides: Mapper.train

Parameters:

dataset : Dataset
Dataset to operate on
*args
Optional positional arguments to pass to _train of subclass
**kwargs
Optional keyword arguments to pass to _train of subclass

_train(self, dataset)

source code 

Worker method. Needs to be implemented by subclass.

This method has to train the mapper and store the resulting transformation matrix in self._proj.

forward(self, data, demean=None)

source code 
Perform forward projection.
Parameters:
  • data, ndarray - Data array to map
  • demean, boolean, |, None - Override demean setting for this method call.
Returns:
NumPy array
Overrides: Mapper.forward

reverse(self, data)

source code 
Reproject (reconstruct) data into the original feature space.
Returns:
NumPy array
Overrides: Mapper.reverse

getInSize(self)

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

getOutSize(self)

source code 
Returns the number of components to project on.
Overrides: Mapper.getOutSize

selectOut(self, outIds)

source code 
Choose a subset of components (and remove all others).
Parameters:
  • outIds, sequence - Subset of ids of the current feature in OUT space to keep.
Overrides: Mapper.selectOut

Class Variable Details [hide private]

_DEV__doc__

Value:
"""Think about renaming `demean`, may be `translation`?"""

proj

Value:
property(fget= lambda self: self._proj, doc= "Projection matrix")