Multivariate Pattern Analysis in Python |
Bases: mvpa.mappers.base.Mapper
Meta mapper that embedded a chain of other mappers.
Each mapper in the chain is called successively to perform forward or reverse mapping.
Note
In its current implementation the ChainMapper treats all but the last mapper as simple pre-processing (in forward()) or post-processing (in reverse()) steps. All other capabilities, e.g. training and neighbor metrics are provided by or affect only the last mapper in the chain.
With respect to neighbor metrics this means that they are determined based on the input space of the last mapper in the chain and not on the input dataspace of the ChainMapper as a whole
Parameters: |
|
---|
Calls all mappers in the chain successively.
Parameters: | data – data to be chain-mapped. |
---|
Returns the size of the entity in input space
Get the ids of the neighbors of a single feature in output dataspace.
Note
The neighbors are determined based on the input space of the last mapper in the chain and not on the input dataspace of the ChainMapper as a whole!
Parameters: |
|
---|
Returns a list of outIds
Returns the size of the entity in output space
Calls all mappers in the chain successively, in reversed order.
Parameters: | data (array) – data array to be reverse mapped into the orginal dataspace. |
---|
Remove some elements from the last mapper in the chain.
Parameters: | outIds (sequence) – All output feature ids to be selected/kept. |
---|
Bases: mvpa.mappers.base.Mapper
Meta mapper that combines several embedded mappers.
This mapper can be used the map from several input dataspaces into a common output dataspace. When forward() is called with a sequence of data, each element in that sequence is passed to the corresponding mapper, which in turned forward-maps the data. The output of all mappers is finally stacked (horizontally or column or feature-wise) into a single large 2D matrix (nsamples x nfeatures).
CombinedMapper fully supports forward and backward mapping, training, runtime selection of a feature subset (in output dataspace) and retrieval of neighborhood information.
Parameters: |
|
---|
Map data from the IN spaces into to common OUT space.
Parameters: | data (sequence) – Each element in the data sequence is passed to the corresponding embedded mapper and is mapped individually by it. The number of elements in data has to match the number of embedded mappers. Each element is data has to provide the same number of samples (first dimension). |
---|---|
Return type: | array |
Returns: | Horizontally stacked array of all embedded mapper outputs. |
Returns the size of the entity in input space
Get the ids of the neighbors of a single feature in output dataspace.
Parameters: |
|
---|
Returns a list of outIds
Returns the size of the entity in output space
Reverse map data from OUT space into the IN spaces.
Parameters: | data (array) – Single data array to be reverse mapped into a sequence of data snippets in their individual IN spaces. |
---|---|
Return type: | list |
Remove some elements and leave only ids in ‘out’/feature space.
Note
The subset selection is done inplace
Parameters: | outIds (sequence) – All output feature ids to be selected/kept. |
---|
Trains all embedded mappers.
The provided training dataset is splitted appropriately and the corresponding pieces are passed to the train() method of each embedded mapper.
Parameters: | dataset (Dataset or subclass) – A dataset with the number of features matching the outSize of the CombinedMapper. |
---|
Bases: object
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
Parameters: | metric (Metric) – Optional metric |
---|
Map data from the IN dataspace into OUT space.
Translate a feature id into a coordinate/index in input space.
Such a translation might not be meaningful or even possible for a particular mapping algorithm and therefore cannot be relied upon.
Returns the size of the entity in input space
To make pylint happy
Get feature neighbors in input space, given an id in output space.
This method has to be reimplemented whenever a derived class does not provide an implementation for getInId().
Return the list of coordinates for the neighbors.
Parameters: |
|
---|
XXX See TODO below: what to return – list of arrays or list of tuples?
Return the list of coordinates for the neighbors.
By default it simply constructs the list based on the generator returned by getNeighbor()
Returns the size of the entity in output space
Validate id in IN space.
Override if IN space is not simly a 1D vector
Validate feature id in OUT space.
Override if OUT space is not simly a 1D vector
To make pylint happy
Reverse map data from OUT space into the IN space.
Limit the OUT space to a certain set of features.
Parameters: | outIds (sequence) – Subset of ids of the current feature in OUT space to keep. |
---|
To make pylint happy
Perform training of the mapper.
This method is called to put the mapper in a state that allows it to perform to intended mapping.
Parameters: | dataset (Dataset or subclass) – |
---|
Note
The default behavior of this method is to do nothing.
Bases: mvpa.mappers.base.Mapper
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.
Initialize the ProjectionMapper
Parameters: |
|
---|
Perform forward projection.
Parameters: |
|
---|---|
Return type: | NumPy array |
Returns the number of original features.
Returns the number of components to project on.
Projection matrix
Backprojection matrix
Reproject (reconstruct) data into the original feature space.
Return type: | NumPy array |
---|
Choose a subset of components (and remove all others).
Determine the projection matrix.
Parameters: |
|
---|