Recursive feature elimination.
A FeaturewiseMeasure is used to compute sensitivity maps given a certain dataset. These sensitivity maps are in turn used to discard unimportant features. For each feature selection the transfer error on some testdatset is computed. This procedure is repeated until a given StoppingCriterion is reached.
Notes
Available conditional attributes:
(Conditional attributes enabled by default suffixed with +)
References
Examples
There are multiple possible ways to design an RFE. Here is one example which would rely on a SplitClassifier to extract sensitivities and provide estimate of performance (error)
>>> # Lazy import
>>> from mvpa2.suite import *
>>> rfesvm_split = SplitClassifier(LinearCSVMC(), OddEvenPartitioner())
>>> # design an RFE feature selection to be used with a classifier
>>> rfe = RFE(rfesvm_split.get_sensitivity_analyzer(
... # take sensitivities per each split, L2 norm, mean, abs them
... postproc=ChainMapper([ FxMapper('features', l2_normed),
... FxMapper('samples', np.mean),
... FxMapper('samples', np.abs)])),
... # use the error stored in the confusion matrix of split classifier
... ConfusionBasedError(rfesvm_split, confusion_state='stats'),
... # we just extract error from confusion, so need to split dataset
... Repeater(2),
... # select 50% of the best on each step
... fselector=FractionTailSelector(
... 0.50,
... mode='select', tail='upper'),
... # and stop whenever error didn't improve for up to 10 steps
... stopping_criterion=NBackHistoryStopCrit(BestDetector(), 10),
... # we just extract it from existing confusion
... train_pmeasure=False,
... # but we do want to update sensitivities on each step
... update_sensitivity=True)
>>> clf = FeatureSelectionClassifier(
... LinearCSVMC(),
... # on features selected via RFE
... rfe,
... # custom description
... descr='LinSVM+RFE(splits_avg)' )
Initialize recursive feature elimination
Parameters : | fmeasure : FeaturewiseMeasure pmeasure : Measure
splitter: Splitter :
fselector : Functor
update_sensitivity : bool
enable_ca : None or list of str
disable_ca : None or list of str
bestdetector : Functor
stopping_criterion : Functor
train_clf : bool
filler : optional
auto_train : bool
force_train : bool
space: str, optional :
postproc : Node instance, optional
descr : str
|
---|