[pymvpa] SVM + RFE
Arman Eshaghi
arman.eshaghi at gmail.com
Mon Jan 27 14:10:54 UTC 2014
Dear all,
I'm struggling with recursive feature selection, a meta classifier (clf),
and the final cross validation. Below is what I have done and what I get as
error. I would very much appreciate if you could help me here.
*#from rfe manual*
*rfe* = RFE(rfesvm_split.get_sensitivity_analyzer(postproc = ChainMapper([
FxMapper('features', l2_normed), FxMapper('samples', np.mean),
FxMapper('samples', np.abs)])), ConfusionBasedError(rfesvm_split,
confusion_state='stats'),
Repeater(2), fselector=FractionTailSelector(0.50, mode = 'select', tail=
'upper'), stopping_criterion=NBackHistoryStopCrit(BestDetector(), 10),
train_pmeasure=False, update_sensitivity=True)
*#Meta-classifier with SVM as the final classifier and rfe as feature
selector*
*clf*=FeatureSelectionClassifier(LinearCSVMC(), rfe, descr='SVM+RFE')
*#cross-validation*
*cvte*=CrossValidation(clf, HalfPartitioner(), enable_ca=['stats'])
*#running the analysis*
*results*=cvte(MyData)
*ERRORS:*
In [37]: results=cvte(gm_lt)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-37-a9da6f9cc192> in <module>()
*----> 1 results=cvte(gm_lt)*
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in __call__(self,
ds)
257 "used and auto training is
disabled."
258 % str(self))
*--> 259 return super(Learner, self).__call__(ds)*
260
261
/usr/lib64/python2.6/site-packages/mvpa2/base/node.pyc in __call__(self, ds)
109
110 self._precall(ds)
*--> 111 result = self._call(ds)*
112 result = self._postcall(ds, result)
113
/usr/lib64/python2.6/site-packages/mvpa2/measures/base.pyc in _call(self,
ds)
495 # always untrain to wipe out previous stats
496 self.untrain()
*--> 497 return super(CrossValidation, self)._call(ds)*
498
499
/usr/lib64/python2.6/site-packages/mvpa2/measures/base.pyc in _call(self,
ds)
324 ca.datasets.append(sds)
325 # run the beast
*--> 326 result = node(sds)*
327 # callback
328 if not self._callback is None:
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in __call__(self,
ds)
257 "used and auto training is
disabled."
258 % str(self))
*--> 259 return super(Learner, self).__call__(ds)*
260
261
/usr/lib64/python2.6/site-packages/mvpa2/base/node.pyc in __call__(self, ds)
109
110 self._precall(ds)
*--> 111 result = self._call(ds)*
112 result = self._postcall(ds, result)
113
/usr/lib64/python2.6/site-packages/mvpa2/measures/base.pyc in _call(self,
ds)
589 for i in
dstrain.get_attr(splitter.get_space())[0].unique])
590 # ask splitter for first part
*--> 591 measure.train(dstrain)*
592 # cleanup to free memory
593 del dstrain
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in train(self, ds)
130 # things might have happened during pretraining
131 if ds.nfeatures > 0:
*--> 132 result = self._train(ds)*
133 else:
134 warning("Trying to train on dataset with no
features present")
/usr/lib64/python2.6/site-packages/mvpa2/clfs/meta.pyc in _train(self,
dataset)
1346 # XXX: should training be done using whole dataset or just
samples
1347 # YYY: in some cases labels might be needed, thus better
full dataset
*-> 1348 self.__mapper.train(dataset)*
1349
1350 # for train() we have to provide dataset -- not just
samples to train!
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in train(self, ds)
130 # things might have happened during pretraining
131 if ds.nfeatures > 0:
*--> 132 result = self._train(ds)*
133 else:
134 warning("Trying to train on dataset with no
features present")
/usr/lib64/python2.6/site-packages/mvpa2/featsel/rfe.pyc in _train(self, ds)
246 # Compute sensitivity map
247 if self.__update_sensitivity or sensitivity == None:
*--> 248 sensitivity = self._fmeasure(wdataset)*
249 if len(sensitivity) > 1:
250 raise ValueError(
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in __call__(self,
ds)
251 debug('LRN', "Auto-training %s on %s",
252 (self, ds))
*--> 253 self.train(ds)*
254 else:
255 # we always have to have trained before using a
learner
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in train(self, ds)
130 # things might have happened during pretraining
131 if ds.nfeatures > 0:
*--> 132 result = self._train(ds)*
133 else:
134 warning("Trying to train on dataset with no
features present")
/usr/lib64/python2.6/site-packages/mvpa2/measures/base.pyc in _train(self,
dataset)
805 True: "although it was trained previously"}
806 [clf.trained]))
*--> 807 return clf.train(dataset)*
808
809
/usr/lib64/python2.6/site-packages/mvpa2/base/learner.pyc in train(self, ds)
130 # things might have happened during pretraining
131 if ds.nfeatures > 0:
*--> 132 result = self._train(ds)*
133 else:
134 warning("Trying to train on dataset with no
features present")
/usr/lib64/python2.6/site-packages/mvpa2/clfs/meta.pyc in _train(self,
dataset)
1268
1269 if ca.is_enabled("stats"):
*-> 1270 predictions = clf.predict(split[1])*
1271
self.ca.stats.add(split[1].sa[targets_sa_name].value,
1272 predictions,
*IndexError: list index out of range*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20140127/9c09e109/attachment.html>
More information about the Pkg-ExpPsy-PyMVPA
mailing list