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