[pymvpa] 回复:Re: How could I know which features were selected by feature selection?

ibinliu at sina.com ibinliu at sina.com
Tue Apr 19 09:27:01 UTC 2016


Hi Nick,Thank you very much for your reply!I typed print clf.mapper.slicearg and it returned something like [300, 301,...]. However, I still don't know how to export features from PyMVPA (sorry I'm not very familiar with PyMVPA). I'd like to see which brain regions were selected. And maybe i shouldn't combine crossvalidation with feature select and use the selected voxels as a mask.Any suggestions?Best,Bin Liu
----- 原始邮件 -----
发件人:Nick Oosterhof <n.n.oosterhof at googlemail.com>
收件人:ibinliu at sina.com, Development and support of PyMVPA <pkg-exppsy-pymvpa at lists.alioth.debian.org>
主题:Re: [pymvpa] How could I know which features were selected by feature selection?
日期:2016年04月19日 16点51分


> On 19 Apr 2016, at 09:31, <ibinliu at sina.com> <ibinliu at sina.com> wrote:
> 
> Hi all,
> 
> I performed feature selection using anova and wanted the features back to NIfTI. I used the following comment lines but encountered an error:
> 
> 
> 
> clf = LinearCSVMC()
> 
> fsel = SensitivityBasedFeatureSelection(OneWayAnova(),
> 
>                                         FixedNElementTailSelector(2000, mode='select', tail='upper'))
> 
> 
> 
> fclf = FeatureSelectionClassifier(clf, fsel)
> 
> 
> 
> cvte = CrossValidation(fclf, NFoldPartitioner(),
> 
>                        errorfx=lambda p, t: np.mean(p == t),
> 
>                        enable_ca=['stats'])
> 
> cv_results = cvte(ds)
> 
> 
> 
> final_dataset = fclf.mapper.forward(ds)
> 
> 
> 
> print final_dataset
> 
> <Dataset: 128x2000 at float32, <sa: chunks,targets,time_coords,time_indices>, <fa: voxel_indices>, <a: imgaffine,imghdr,imgtype,mapper,voxel_dim,voxel_eldim>>
> 
> 
> 
> nimg = map2nifti(final_dataset)
> 
> nimg.to_filename('features.nii')
> 
> ValueError: array is not broadcastable to correct shape
> 
> 
> 
> Has anyone else had the same errors before?
According to the FAQ [1] it would seem that the clf.mapper.slicearg contains which features were selected. 
It seems you are doing crossvalidation combined with feature selection, which means that for every fold a different subset of features may be selected for training the classifier. As such, you cannot directly convert which features were selected to a nifti volume - except, if you compute a separate volume for each fold.
[1] http://www.pymvpa.org/faq.html#how-do-i-know-which-features-were-finally-selected-by-a-classifier-doing-feature-selection
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20160419/eb5f9495/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list