[pymvpa] Classification Questions

Jessica Goold jessi.goold at gmail.com
Sat Jan 4 19:42:53 UTC 2014


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20140104/4f87734a/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list