1
2
3
4
5
6
7
8
9 """Data mapper"""
10
11 __docformat__ = 'restructuredtext'
12
13 from mvpa.misc.vproperty import VProperty
14 from mvpa.base.dochelpers import enhancedDocString
15
16
18 """Interface to provide mapping between two spaces: in and out.
19 Methods are prefixed correspondingly. forward/reverse operate
20 on the entire dataset. get(In|Out)Id[s] operate per element::
21
22 forward
23 in ---------> out
24 <--------/
25 reverse
26
27 Subclasses should define 'dsshape' and 'nfeatures' properties that point to
28 `getInShape` and `getOutSize` respectively. This cannot be
29 done in the baseclass as standard Python properties would still point to
30 the baseclass methods.
31 """
33 """Does nothing."""
34 pass
35
36
37 __doc__ = enhancedDocString('Mapper', locals())
38
39
41 """Map data from the original dataspace into featurespace.
42 """
43 raise NotImplementedError
44
45
47 """Calls the mappers forward() method.
48 """
49 return self.forward(data)
50
51
53 """Reverse map data from featurespace into the original dataspace.
54 """
55 raise NotImplementedError
56
57
58 - def train(self, dataset):
59 """Sub-classes have to override this method if the mapper need
60 training.
61 """
62 pass
63
64
66 """Returns the dimensionality specification of the original dataspace.
67
68 XXX -- should be deprecated and might be substituted
69 with functions like getEmptyFrom / getEmptyTo
70 """
71 raise NotImplementedError
72
73
75 """
76 Returns the shape (or other dimensionality speicification)
77 of the destination dataspace.
78 """
79 raise NotImplementedError
80
81
83 """Returns the size of the entity in input space"""
84 raise NotImplementedError
85
86
88 """Returns the size of the entity in output space"""
89 raise NotImplementedError
90
91
93 """Remove some elements and leave only ids in 'out'/feature space"""
94 raise NotImplementedError
95
96
97 nfeatures = VProperty(fget=getOutSize)
98