[pymvpa] SMLR weights

Yaroslav Halchenko debian at onerussian.com
Thu Jan 22 16:54:50 UTC 2009


> I just started learning PyMVPA and ran some structural imaging data of patients and controls.

I think I had idea for a similar project to what you are doing, even got some
data but never finished it ;) So, let me just prime you that Python + PyMVPA should be
the right tool ;)

> To get SMLR weights, I tried both SMLRWeights(SMLR()) and SMLR().getSensitivityAnalyzer(). Although they give the same selected voxels, but the values are different. Which one should I use?

actually any, BUT...

I think that you hit a bit of inconsistency of 'default arguments'. If
you run

sana1 = SMLRWeights(SMLR())
sana2 = SMLR().getSensitivityAnalyzer()

and then print their representations:

In [3]:sana1
Out[3]:SMLRWeights(clf=SMLR())

In [4]:sana2
Out[4]:SMLRWeights(clf=SMLR(), combiner=<function SecondAxisMaxOfAbs at 0x2ae989d65ed8>)

you see that in the 2nd case you obtain a default combiner (across
various labels), which takes maximal sensitivity, whenever in the first one it
remains with the default one, which, is actually not printed since it is
default one, but it is:

In [20]:sana1._FeaturewiseDatasetMeasure__combiner
Out[20]:<function SecondAxisSumOfAbs at 0x2ae989d65e60>

NB I just pushed commit which exposes combiner and transformers (e.g. as
   'sana1.combiner')

to analyze what has actually happened we can create a sensitivity
analyzer without any combiner (which imho should be our default):

sana3 = SMLR().getSensitivityAnalyzer(combiner=None)
sens3 = sana3(dataset)

sens3.shape
Out[23]:(530, 2)

whenever for the first 2 we had:

In [24]:sens1.shape
Out[24]:(530,)

In [25]:sens2.shape
Out[25]:(530,)

and actual values:

In [26]:sens1[:5]
Out[26]:array([ 0.        ,  0.61533554,  0.30644191,  0.4684788 ,  0.14939858])

In [27]:sens2[:5]
Out[27]:array([ 0.        ,  0.5879101 ,  0.15376068,  0.27464827,  0.09092551])
a
In [28]:sens3[:5]
Out[28]:
array([[ 0.        ,  0.        ],
       [-0.58819795,  0.02891341],
       [-0.15264051,  0.15382499],
       [ 0.27456963, -0.19295715],
       [ 0.09099318, -0.06050513]])

> I assumed that the dot product of weights and selected voxel values
> (gray matter density in my case) would give an idea about how the two groups
> could be separated, but it looks not the case. Although the prediction accuracy
> is pretty good (85%), the dot products for the two groups are largely
> overlapped. I guess I just misunderstood it. Could you give me some idea about
> what the weights are about? 

Weights for linear classifier are just coefficients of the normal of the
separating plane ;) just than banal ;)

so, I think you just need to look at those sensitivity values -- check out 
doc/examples/sensanas.py

if you want to get idea on how each sample is important for the classification,
then it is a different story and you should follow Michael's advice to checkout
doc/examples/pylab_2d.py example.

> Thanks for providing such an excellent package!

hopefully you find it useful (and I bet you will after you help us out to
sort out all kinds of problems like the one you encountered. BTW -- we very
much welcome contributions : code/documentation/examples ;))

> Best regard, Frank

-- 
Yaroslav Halchenko
Research Assistant, Psychology Department, Rutgers-Newark
Student  Ph.D. @ CS Dept. NJIT
Office: (973) 353-1412 | FWD: 82823 | Fax: (973) 353-1171
        101 Warren Str, Smith Hall, Rm 4-105, Newark NJ 07102
WWW:     http://www.linkedin.com/in/yarik        



More information about the Pkg-ExpPsy-PyMVPA mailing list