Mapping definition |
Mappings are typically defined inside functions that compute or apply a mapping, e.g. inside classifiers or routines for feature reduction. This section is thereby primarily of relevance for advanced PRTools
users who want to extend the set of available mappings. Starting users or those who focus on applications applying given procedures may skip it, or just have a quick look at the below table which describes all fields of a mapping variable.
The mapping
constructor looks like
W = mapping(command,type,data,labels,size_in,size_out)
command
is a string with the name of the mapping (and thereby also the name of the m-file) that should be called to execute commands like B = A*W
, in which A
is usually a dataset, and occasionally another mapping.
type
is the mapping type, 'fixed'
, 'untrained'
, 'trained'
or 'combiner'
. See the description
op mapping types.
data
is a structure or a cell array of all information that the specific procedure (name) expects and needs to perform the mapping.
labels
is a set of strings or numbers that will be used to annotate the resulting dataset B with feature labels (to be stored in its featlab field). The typical use is that labels stores the class names of A (its lablist field) in case of a classifier.
size_in
is the dimension of the input space (number of features of A).
size_out
is the dimension of the output space (number of features of B).
Consequently, if the dataset A
has a size of [m,size_in]
and W
has a size of [size_in,size_out]
, then the mapping B
will have a size of [m,size_out]
. Thereby B = A*W
is consistent with a Matlab
expression in which B
, A
and W
are matrices of the corresponding sizes.
PRTools
uses the values of size_in
and size_out
mainly for error detection and returning appropriate error messages. In many cases the values may be replaced by 0, e.g. when the sizes are unknown at the moment of defining the mapping. This will not effect a correct execution, but may result in badly understandable error messages in case a dataset A
of a wrong size is used for input.
A full list of all information stored in a mapping can be found by converting a mapping in a structure.
a = iris; w = pca(a,2); struct(w) % mapping_file: 'affine' % mapping_type: 'trained' % data: [1x1 struct] % labels: [2x1 double] % size_in: 4 % size_out: 2 % scale: 1 % out_conv: 0 % cost: [] % name: 'PCA to 2D' % user: [] % version: {[1x1 struct] '07-Apr-2011 15:21:01'}
All fields have a corresponding set-command (e.g. setdata
) to store it and a get-command (e.g. getdata
) to retrieve it. In some cases not the exact fields are retrieved but some derived data. In the table more information is given.
> The fields of the mapping structure | |
| The name of the command (m-file) that executes the mapping. |
mapping_type | The type of the mapping: fixed, untrained, trained or combiner. |
data | A structure or a cell array with all information needed to execute the mapping. |
labels | Array with features used to annotate the features (featlab) of the output dataset. |
size_in | Input dimensionality. Number of features of the input dataset. |
size_out | Output dimensionality. Number of features of the output dataset. |
scale | A scalar or a vector to scale the output features. |
out_conv | Type of desired output conversion. |
cost | Classification costs in case the mapping defines a classifier. |
name | String with a name, just used for annotation of plots and other outputs. |
user | User defined field. |
version | PRTools version number and date of creating the mapping. |
The mapping fields might also be accessed by structural indexing.
R.P.W. Duin
, January 28, 2013Mapping definition |