[pymvpa] Proper input format for 'weight' & 'weight_label' attribute in classifiers

Taku Ito taku.ito1 at gmail.com
Mon Apr 7 22:18:14 UTC 2014


Hi all,

I'm looking to run a 3-way classification with LinearCSVMC(), but I'd like
to assign different weights to each of the labels.

That being said, I'm a little confused as to how I should input the weights
for each label, since I'm not exactly sure how the SVM would know how to
map the correct weights to the labels assigned in the data set.  My first
attempt went something like this:

weights = [1,5,10]
weight_labels = 'class1', 'class2', 'class3']  #Where class1 corresponds to
one of the target labels, class 2 corresponds to the second target label,
and so on.

clf = LinearCSVMC(weight=weights, weight_label=weight_labels)

This read out the following error:

FailedToTrainError: invalid literal for int() with base 10: 'class1'
I assumed (falsely) that by inputting the corresponding labels in the data
set to the weight_labels attribute that it would correctly assign the
weights to the correct labels.  Anyhow, I subsequently changed the
weight_labels to integers, i.e.,
weight_labels=[0, 1, 2]

and it seemed to run fine.  However, I'm not exactly sure how PyMVPA
interfaces with the actual SVM package, so I'm worried it may be assigning
weights to the incorrect labels.  I also contemplated the thought that
maybe the weights should be inputted as an array of length n, where
n=number of samples being funneled into the classifier, but I figured I
should clarify on the forum first before I guessed around.

Thank you in advance for any advice!

Best,
Taku
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20140407/ab7ca71c/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list