[pymvpa] Recursive Feature Elimination errors
Mike E. Klein
michaeleklein at gmail.com
Fri Sep 16 22:30:31 UTC 2011
Hi all,
I'm trying to get a very "basic" script working that implements RFE. I'm not
a coder, but I've read the tutorial and am trying to follow others' scripts
as best as possible. Generally, I hope to do small modifications of standard
scripts (changing my 4d bold data, my mask, attributes.txt file, and label
names).
I tried using the code at http://www.pymvpa.org/featsel.html, but got the
errors mentioned here (
http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/2011q2/001747.html),
as I'm running v0.6. (I must also mention that the 0.4, 0.6 (with multiple
RCs), and coming 2.0 naming has been fairly difficult to navigate.)
Anyway, I followed that thread's advice and changed the method from
camelCase naming to incorporate underscores: that line of code now reads
"sensitivity_analyzer=rfesvm_split.get_sensitivity_analyzer("
Python is now reporting a long TypeError which I've pasted below. I've also
attached my script. I've gotten simpler scripts (that incorporate no feature
selection) to work, so the problem should not be with my nifti or attribute
files.
Thanks again for any and all help: I only have the manual, google, and this
listserv to rely upon when problems arise!
Best,
Mike
In [24]: FtSelClf = FeatureSelectionClassifier(
....: # use a linear SVM classifier:
....: clf = LinearCSVMC(),
....: # on features selected via RFE
....: feature_selection = RFE(
....: # based on sensitivity of a clf which does splitting
internally
....: sensitivity_analyzer=rfesvm_split.get_sensitivity_analyzer(
....: transformer=Absolute,combiner=lambda x:
N.sum(x,axis=0)),
....: transfer_error=ConfusionBasedError(
....: rfesvm_split,
....: confusion_state="confusion"),
....: # and whose internal error we use
....: feature_selector=FractionTailSelector(
....: 0.3, mode='discard', tail='lower'),
....: # remove 20% of features at each step
....: #enable_states=['feature_ids'],
....: # update sensitivity at each step
....: update_sensitivity=True),
....: enable_states=['feature_ids'],
....: descr='LinSVM+RFE(splits_avg)')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/mike/Documents/fMRI_analysis/PyMVPA-analysis/subjects/0-pemberton/<ipython-input-24-85837272a049>
in <module>()
6 # based on sensitivity of a clf which does splitting
internally
7 sensitivity_analyzer=rfesvm_split.get_sensitivity_analyzer(
----> 8 transformer=Absolute,combiner=lambda x:
N.sum(x,axis=0)),
9 transfer_error=ConfusionBasedError(
10 rfesvm_split,
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/misc/args.pyc
in do_group_kwargs(self, *args_, **kwargs_)
71 if passthrough: kwargs__[k] = skwargs
72 if assign: setattr(self, '_%s' % k, skwargs)
---> 73 return method(self, *args_, **kwargs__)
74 do_group_kwargs.func_name = method.func_name
75 return do_group_kwargs
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/clfs/meta.pyc
in get_sensitivity_analyzer(self, slave_kwargs, **kwargs)
1270 self, sa_attr='splits',
1271
analyzer=self.__clf.get_sensitivity_analyzer(**slave_kwargs),
-> 1272 **kwargs)
1273
1274 partitioner = property(fget=lambda x:x.__partitioner,
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/misc/args.pyc
in do_group_kwargs(self, *args_, **kwargs_)
71 if passthrough: kwargs__[k] = skwargs
72 if assign: setattr(self, '_%s' % k, skwargs)
---> 73 return method(self, *args_, **kwargs__)
74 do_group_kwargs.func_name = method.func_name
75 return do_group_kwargs
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/measures/base.pyc
in __init__(self, clf, analyzer, combined_analyzer, sa_attr, slave_kwargs,
**kwargs)
962 Arguments to pass to created analyzer if analyzer is None
963 """
--> 964 Sensitivity.__init__(self, clf, **kwargs)
965 if combined_analyzer is None:
966 # sanitarize kwargs
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/measures/base.pyc
in __init__(self, clf, force_train, **kwargs)
756 # by default auto train
757 kwargs['auto_train'] = kwargs.get('auto_train', True)
--> 758 FeaturewiseMeasure.__init__(self, force_train=force_train,
**kwargs)
759
760 _LEGAL_CLFS = self._LEGAL_CLFS
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/measures/base.pyc
in __init__(self, **kwargs)
615
616 def __init__(self, **kwargs):
--> 617 Measure.__init__(self, **kwargs)
618
619
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/measures/base.pyc
in __init__(self, null_dist, **kwargs)
85 certain value of the computed measure.
86 """
---> 87 Learner.__init__(self, **kwargs)
88
89 null_dist_ = auto_null_dist(null_dist)
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/base/learner.pyc
in __init__(self, auto_train, force_train, **kwargs)
76 All arguments are passed to the baseclass.
77 """
---> 78 Node.__init__(self, **kwargs)
79 self.__is_trained = False
80 self.__auto_train = auto_train
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/base/node.pyc
in __init__(self, space, postproc, **kwargs)
52 result dataset. If None, nothing is done.
53 """
---> 54 ClassWithCollections.__init__(self, **kwargs)
55 self.set_space(space)
56 self.set_postproc(postproc)
/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/mvpa/base/state.pyc
in __init__(self, descr, **kwargs)
855 "Unexpected keyword argument %s=%s for
%s." \
856 % (arg, argument, self) \
--> 857 + " Valid parameters are %s" %
known_params
858
859 ## Initialize other base classes
TypeError: Unexpected keyword argument transformer=<function Absolute at
0x1098665f0> for <BoostedClassifierSensitivityAnalyzer>. Valid parameters
are ['base_sensitivities', 'raw_results', 'calling_time', 'training_time',
'null_t', 'null_prob']
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20110916/7cbfe329/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forListServ.py
Type: application/octet-stream
Size: 2111 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20110916/7cbfe329/attachment.obj>
More information about the Pkg-ExpPsy-PyMVPA
mailing list