[pymvpa] EEG dataset and chunks
brice rebsamen
brice.rebsamen at gmail.com
Mon Apr 11 14:26:51 UTC 2011
This is what I want to achieve. I made my own function for now.
def crossValidate(clf, ds, nReps=10, trainRatio=0.8):
# number of samples per target, get the min
N = min(ds.get_nsamples_per_attr('targets').values())
# number of training samples
nTrain = int(N*trainRatio)
# a confusion matrix to store the result
cm = ConfusionMatrix()
for n in range(nReps):
# selected samples for training and testing
dTrain, dTest = [], []
for t in ds.sa['targets'].unique:
idx = np.random.permutation(ds.get_samples_by_attr('targets',t))
dTrain.extend( idx[:nTrain] )
dTest.extend( idx[nTrain:N] )
if clf.trained: clf.untrain()
clf.train(ds[dTrain])
cm.add(ds[dTest].targets,clf.predict(ds[dTest].samples))
return cm
Is there a way to achieve this with CrossValidation? I haven't checked the
method you proposed yet:
CrossValidation(clf,
Balancer(amount=0.8, limit=None, attr='targets',
count=3),
splitter=Splitter('balanced_set', [True, False]))
Regards
Brice
On Fri, Apr 8, 2011 at 11:05 AM, Yaroslav Halchenko
<debian at onerussian.com>wrote:
> eh -- sorry, splitter as an argument came in not even a month ago,
> already after rc2.
> you would need either to wait for rc3 (can be furnished early next week)
> or just build/use pymvpa from sources -- it is quite easy actually
>
> On Fri, 08 Apr 2011, brice rebsamen wrote:
>
> > Thanks,
> > CrossValidation(clf,
> > Balancer(amount=0.8, limit=None, attr='targets',
> > count=3),
> > splitter=Splitter('balanced_set', [True, False]))
> > This seems like a good idea, but I get this error message:
> > TypeError: Unexpected keyword argument splitter=<Splitter> for
> > <CrossValidation>. Valid parameters are ['datasets', 'training_stats',
> > 'raw_results', 'calling_time', 'training_time', 'null_t', 'null_prob',
> > 'stats', 'repetition_results']
> > I think I understand the role of the 'chunks' attribute, and I see how
> > I should use it. I guess my samples are not all independent...
> > Regards
> > Brice
> --
> =------------------------------------------------------------------=
> Keep in touch www.onerussian.com
> Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic
>
> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20110411/f03d760b/attachment.htm>
More information about the Pkg-ExpPsy-PyMVPA
mailing list