[pymvpa] Classification Questions

Chris Johnson effigies at gmail.com
Mon Jan 6 14:01:40 UTC 2014


Okay, that error means your chunks are of the form 1.0 and similar,
not 'A', 'B', 'C' and 'D'.

If you look in your $path/attributes.txt file, what does the first
line look like? I'm going to guess, for some X:

X 1

X is your target, 1 is your chunk (and PyMVPA interprets it as a
float, so prints 1.0). If X is among 'A'..'D', then what you probably
want to use is targets instead of chunks.

fds.sa['runtype'] = [rnames[target] for target in fds.sa.targets]

If not, you'll need to figure out where you 'A'..'D' are coming from.
On the other hand, this doesn't seem like a necessary step, as runtype
is not referenced in the later code.

Cheers,
Chris


On Sat, Jan 4, 2014 at 2:42 PM, Jessica Goold <jessi.goold at gmail.com> wrote:
> Hi Chris,
>
> Thanks for getting back to me so fast. When i try to run that I get this
> error:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> KeyError: 1.0
>
> I also changed the code a little because I saw the differences in
> preprocessing for wanting to run an nfoldpartitioner. I think it could have
> to do with what you think though because when i run either LinearNuSVMC or
> SMLR it gives me way too many samples back of accuracies. Here's the
> slightly changed code:
>
> from mvpa2.suite import *
> import numpy as np
> import scipy.stats as sp
> import scipy.io
> import nibabel
> import random
> path = '/home/menglab/JG/AP/concat/Session 1'
> attr = SampleAttributes(os.path.join(path, 'attributes.txt'))
>
> fds = fmri_dataset(samples=os.path.join(path, 'ap_all.nii'), targets =
> attr.targets, chunks=attr.chunks, mask = os.path.join(path, 'rFFA_AP1.nii'))
>
> poly_detrend(fds, polyord=1, chunks_attr='chunks')
> fds = fds[fds.sa.targets != 'none']
>
> rnames = {'A': 'Face', 'B': 'High_Face', 'C': 'Low_Face', 'D': 'Non_Face'}
> fds.sa['runtype'] = [rnames[chunks] for chunks in fds.sa.chunks]
> #error happens here
>
> clf = LinearCSVMC()
> cvte = CrossValidation(clf, NFoldPartitioner(), errorfx=lambda p, t:
> np.mean(p == t))
> cv_results = cvte(fds)
>
> Thanks!
> Jessica
>
>
> On Sat, Jan 4, 2014 at 2:23 PM, Chris Johnson <effigies at gmail.com> wrote:
>>
>> This line is setting fds.sa['runtype'] to a list with a single boolean
>> (probably [False]).
>>
>> > fds.sa['runtype'] = [rnames in fds.sa.chunks]
>>
>> I would guess what you want is:
>>
>> > fds.sa['runtype'] = [rnames[chunk] for chunk in fds.sa.chunks]
>>
>> Hopefully that's all the problem is. Otherwise the code looks like it
>> should run.
>>
>> Chris
>>
>>
>> On Sat, Jan 4, 2014 at 2:13 PM, Jessica Goold <jessi.goold at gmail.com>
>> wrote:
>> > Hello,
>> >
>> > I'm trying to run my first classification analysis on my own data, and
>> > every
>> > classification type seems to work except LinearCSVMC(). I'm attaching my
>> > python file of code and I've pasted the error I get at the bottom of it.
>> > Any
>> > help on why this is happening would be great!
>> >
>> > Thank you,
>> > Jessica
>> >
>> > _______________________________________________
>> > Pkg-ExpPsy-PyMVPA mailing list
>> > Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
>> >
>> > http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa
>>
>> _______________________________________________
>> Pkg-ExpPsy-PyMVPA mailing list
>> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
>> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa
>
>
>
> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa



More information about the Pkg-ExpPsy-PyMVPA mailing list