Table Of Contents

Previous topic

mvpa.mappers.wavelet

Next topic

mvpa.clfs.blr

This Page

Quick search

mvpa.clfs.base

Base class for all classifiers.

At the moment, regressions are treated just as a special case of classifier (or vise verse), so the same base class Classifier is utilized for both kinds.

The comprehensive API documentation for this module, including all technical details, is available in the Epydoc-generated API reference for mvpa.clfs.base (for developers).

Classifier

class mvpa.clfs.base.Classifier(**kwargs)

Bases: mvpa.misc.state.ClassWithCollections

Abstract classifier class to be inherited by all classifiers

Note

Available state variables:

  • feature_ids: Feature IDS which were used for the actual training.
  • predicting_time+: Time (in seconds) which took classifier to predict
  • predictions+: Most recent set of predictions
  • trained_dataset: The dataset it has been trained on
  • trained_labels+: Set of unique labels it has been trained on
  • training_confusion: Confusion matrix of learning performance
  • training_time+: Time (in seconds) which took classifier to train
  • values+: Internal classifier values the most recent predictions are based on

(States enabled by default are listed with +)

See also

Please refer to the documentation of the base class for more information:

ClassWithCollections

Cheap initialization.

Parameters:
  • enable_states (None or list of basestring) – Names of the state variables which should be enabled additionally to default ones
  • disable_states (None or list of basestring) – Names of the state variables which should be disabled
clone()

Create full copy of the classifier.

It might require classifier to be untrained first due to present SWIG bindings.

TODO: think about proper re-implementation, without enrollment of deepcopy

getSensitivityAnalyzer(**kwargs)
Factory method to return an appropriate sensitivity analyzer for the respective classifier.
isTrained(dataset=None)

Either classifier was already trained.

MUST BE USED WITH CARE IF EVER

predict(data)

Predict classifier on data

Shouldn’t be overridden in subclasses unless explicitly needed to do so. Also subclasses trying to call super class’s predict should call _predict if within _predict instead of predict() since otherwise it would loop

repredict(data, **kwargs)

Helper to avoid check if data was changed actually changed

Useful if classifier was (re)trained but with the same data (so just parameters were changed), so that it could be repredicted easily (on the same data as before) without recomputing for instance train/test kernel matrix. Should be used with caution and always compared to the results on not ‘retrainable’ classifier. Some additional checks are enabled if debug id ‘CHECK_RETRAIN’ is enabled, to guard against obvious mistakes.

Parameters:
  • data – data which is conventionally given to predict
  • kwargs – that is what _changedData gets updated with. So, smth like (params=['C'], labels=True) if parameter C and labels got changed
retrain(dataset, **kwargs)

Helper to avoid check if data was changed actually changed

Useful if just some aspects of classifier were changed since its previous training. For instance if dataset wasn’t changed but only classifier parameters, then kernel matrix does not have to be computed.

Words of caution: classifier must be previously trained, results always should first be compared to the results on not ‘retrainable’ classifier (without calling retrain). Some additional checks are enabled if debug id ‘CHECK_RETRAIN’ is enabled, to guard against obvious mistakes.

Parameters:
  • kwargs – that is what _changedData gets updated with. So, smth like (params=['C'], labels=True) if parameter C and labels got changed
summary()
Providing summary over the classifier
train(dataset)

Train classifier on a dataset

Shouldn’t be overridden in subclasses unless explicitly needed to do so

trained
untrain()
Reset trained state

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the Classifier documentation.

Full API documentation of Classifier in module mvpa.clfs.base.