Package mvpa :: Package featsel :: Module rfe :: Class RFE

[hide private]
[frames] | no frames]

# Class RFE

source code

Recursive feature elimination.

A FeaturewiseDatasetMeasure 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.

Such strategy after
  Guyon, I., Weston, J., Barnhill, S., & Vapnik, V. (2002). Gene selection for cancer classification using support vector machines. Mach. Learn., 46(1-3), 389--422.
was applied to SVM-based analysis of fMRI data in
  Hanson, S. J. & Halchenko, Y. O. (2008). Brain reading using full brain support vector machines for object recognition: there is no "face identification area". Neural Computation, 20, 486--503.

Nested Classes | [hide private]

Inherited from `misc.state.ClassWithCollections`: `__metaclass__`

Instance Methods | [hide private]

__init__(self, sensitivity_analyzer, transfer_error, feature_selector=FractionTailSelector(0.05), bestdetector=BestDetector(), stopping_criterion=NBackHistoryStopCrit(BestDetector()), train_clf=None, update_sensitivity=True, **kargs) Initialize recursive feature elimination | source code

__call__(self, dataset, testdataset) Proceed and select the features recursively eliminating less important ones. | source code

Inherited from `base.FeatureSelection`: `untrain` Inherited from `misc.state.ClassWithCollections`: `__getattribute__`, `__new__`, `__repr__`, `__setattr__`, `__str__`, `reset` Inherited from `object`: `__delattr__`, `__format__`, `__hash__`, `__reduce__`, `__reduce_ex__`, `__sizeof__`, `__subclasshook__`

Class Variables | [hide private]

| errors = `StateVariable()`
| sensitivities = `StateVariable(enabled= False)`
Inherited from `base.FeatureSelection`: `selected_ids` Inherited from `misc.state.ClassWithCollections`: `_DEV__doc__`, `descr`

Instance Variables | [hide private]

| __sensitivity_analyzer Sensitivity analyzer used to call at each step.
| __transfer_error Compute transfer error for each feature set.
| __feature_selector Functor which takes care about removing some features.
| __train_clf Flag whether training classifier is required.
| __update_sensitivity Flag whether sensitivity map is recomputed for each step.
| nfeatures Number of features at each step. Since it is not used by the algorithm it is stored directly in the state variable
| history Store the last step # when the feature was still present

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, sensitivity_analyzer, transfer_error, feature_selector=FractionTailSelector(0.05), bestdetector=BestDetector(), stopping_criterion=NBackHistoryStopCrit(BestDetector()), train_clf=None, update_sensitivity=True, **kargs)
(Constructor)

source code

    Initialize recursive feature elimination

    :Parameters:
        sensitivity_analyzer : FeaturewiseDatasetMeasure object
        transfer_error : TransferError object
            used to compute the transfer error of a classifier based on a
            certain feature set on the test dataset.
            NOTE: If sensitivity analyzer is based on the same
            classifier as transfer_error is using, make sure you
            initialize transfer_error with train=False, otherwise
            it would train classifier twice without any necessity.
        feature_selector : Functor
            Given a sensitivity map it has to return the ids of those
            features that should be kept.
        bestdetector : Functor
            Given a list of error values it has to return a boolean that
            signals whether the latest error value is the total minimum.
        stopping_criterion : Functor
            Given a list of error values it has to return whether the
            criterion is fulfilled.
        train_clf : bool
            Flag whether the classifier in `transfer_error` should be
            trained before computing the error. In general this is
            required, but if the `sensitivity_analyzer` and
            `transfer_error` share and make use of the same classifier it
            can be switched off to save CPU cycles. Default `None` checks
            if sensitivity_analyzer is based on a classifier and doesn't train
            if so.
        update_sensitivity : bool
            If False the sensitivity map is only computed once and reused
            for each iteration. Otherwise the senstitivities are
            recomputed at each selection step.

Overrides: object.__init__

### __call__(self, dataset, testdataset)
(Call operator)

source code

Proceed and select the features recursively eliminating less important ones.

Returns a tuple of two new datasets with the feature subset of `dataset` that had the lowest transfer error of all tested sets until the stopping criterion was reached. The first dataset is the feature subset of the training data and the second the selection of the test dataset.

Parameters:
  - `dataset` (Dataset) - used to compute sensitivity maps and train a classifier to determine the transfer error
  - `testdataset` (Dataset) - used to test the trained classifer to determine the transfer error
Overrides: base.FeatureSelection.__call__