![]() |
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.
Parameter: | data – data to be chain-mapped. |
---|
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
Calls all mappers in the chain successively, in reversed order.
Parameter: | data (array) – data array to be reverse mapped into the orginal dataspace. |
---|
Remove some elements from the last mapper in the chain.
Parameter: | 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).
Note
This mapper can only embbed mappers that transform data into a 2D (nsamples x nfeatures) representation. For mappers not supporting this transformation, consider wrapping them in a ChainMapper with an appropriate post-processing mapper.
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.
Parameter: | 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. |
Get the ids of the neighbors of a single feature in output dataspace.
Parameters: |
|
---|
Returns a list of outIds
Reverse map data from OUT space into the IN spaces.
Parameter: | 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
Parameter: | 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.
Parameter: | 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
Parameter: | metric (Metric) – Optional metric |
---|
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.
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()
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
Limit the OUT space to a certain set of features.
Parameter: | outIds (sequence) – Subset of ids of the current feature in OUT space to keep. |
---|
Perform training of the mapper.
This method is called to put the mapper in a state that allows it to perform to intended mapping.
Parameter: | 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 |
Reproject (reconstruct) data into the original feature space.
Return type: | NumPy array |
---|
Determine the projection matrix.
Parameters: |
|
---|