Package mvpa :: Package misc :: Module transformers
[hide private]
[frames] | no frames]

Source Code for Module mvpa.misc.transformers

 1  #emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  #ex: set sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Simply functors that transform something.""" 
10   
11  __docformat__ = 'restructuredtext' 
12   
13   
14  import numpy as N 
15   
16   
17 -def Absolute(x):
18 """Returns the elementwise absolute of any argument.""" 19 return N.absolute(x)
20 21
22 -def OneMinus(x):
23 """Returns elementwise '1 - x' of any argument.""" 24 return 1 - x
25 26
27 -def Identity(x):
28 """Return whatever it was called with.""" 29 return x
30 31
32 -def FirstAxisMean(x):
33 """Mean computed along the first axis.""" 34 return N.mean(x, axis=0)
35 36
37 -def SecondAxisSumOfAbs(x):
38 """Sum of absolute values along the 2nd axis 39 40 Use cases: 41 - to combine multiple sensitivities to get sense about 42 what features are most influential 43 """ 44 return N.abs(x).sum(axis=1)
45 46
47 -def SecondAxisMaxOfAbs(x):
48 """Max of absolute values along the 2nd axis 49 """ 50 return N.abs(x).max(axis=1)
51 52
53 -def GrandMean(x):
54 """Just what the name suggests.""" 55 return N.mean(x)
56