[pymvpa] Using PLR with multiclass
Neal Morton
mortonne at gmail.com
Wed Mar 1 18:43:01 UTC 2017
I have four classes, so I can’t just use {0,1}. It looks like no matter what the sample attributes of the input dataset are, MulticlassClassifier will send {-1,1} to the classifier.
It looks like I need to either modify what MulticlassClassifier is sending to PLR, or change PLR to handle other labels.
From: Pkg-ExpPsy-PyMVPA <pkg-exppsy-pymvpa-bounces+mortonne=gmail.com at lists.alioth.debian.org> on behalf of Swaroop Guntupalli <swaroopgj at gmail.com>
Reply-To: Development and support of PyMVPA <pkg-exppsy-pymvpa at lists.alioth.debian.org>
Date: Wednesday, March 1, 2017 at 12:38 PM
To: Development and support of PyMVPA <pkg-exppsy-pymvpa at lists.alioth.debian.org>
Subject: Re: [pymvpa] Using PLR with multiclass
Does it help if you assign targets in your sample attributes to {0,1} instead?
On Wed, Mar 1, 2017 at 1:13 PM, Neal Morton <mortonne at gmail.com> wrote:
Is there a way to use PLR with a multiclass problem? When I try to use the MulticlassClassifier, that produces binary labels with -1 and 1. But PLR expects 0 and 1.
The classifier is created like so:
from mvpa2.clfs.plr import PLR
from mvpa2.clfs.meta import MulticlassClassifier
clf = MulticlassClassifier(PLR(lm=10))
When I try to train the classifier on an fMRI dataset with four classes, I get:
Traceback (most recent call last):
File "/home1/03206/mortonne/analysis/bender/mvpa/loc_xval_diag.py", line 98, in <module>
clf.train(ds1)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/base/learner.py", line 137, in train
self._train(ds)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/clfs/meta.py", line 1165, in _train
CombinedClassifier._train(self, dataset)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/clfs/meta.py", line 628, in _train
BoostedClassifier._train(self, dataset)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/clfs/meta.py", line 118, in _train
clf.train(dataset)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/base/learner.py", line 137, in train
self._train(ds)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/clfs/meta.py", line 1053, in _train
self.clf.train(datasetselected)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/base/learner.py", line 137, in train
self._train(ds)
File "/work/IRC/ls5/lib/python2.7/site-packages/mvpa2/clfs/plr.py", line 76, in _train
%(set(d),)
ValueError: Regressors for logistic regression should be [0,1]. Got set([1, -1])
I have the latest versions of meta.py and plr.py. There was a change in PLRWeights to support different values of labels, but that change doesn’t seem to have affected the PLR classifier.
Thanks,
Neal
_______________________________________________
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/20170301/6b90dad3/attachment-0001.html>
More information about the Pkg-ExpPsy-PyMVPA
mailing list