Package mvpa :: Package clfs :: Module smlr :: Class SMLR
[hide private]
[frames] | no frames]

Class SMLR

source code


Sparse Multinomial Logistic Regression `Classifier`.

This is an implementation of the SMLR algorithm published in
:ref:`Krishnapuram et al., 2005 <KCF+05>` (2005, IEEE Transactions
on Pattern Analysis and Machine Intelligence).  Be sure to cite
that article if you use this classifier for your work.

Nested Classes [hide private]

Inherited from misc.state.ClassWithCollections: __metaclass__

Instance Methods [hide private]
 
__init__(self, **kwargs)
Initialize an SMLR classifier.
source code
 
_pythonStepwiseRegression(self, w, X, XY, Xw, E, auto_corr, lambda_over_2_auto_corr, S, M, maxiter, convergence_tol, resamp_decay, min_resamp, verbose, seed=None)
The (much slower) python version of the stepwise regression. I'm keeping this around for now so that we can compare results.
source code
 
_train(self, dataset)
Train the classifier using dataset (Dataset).
source code
 
_unsparsify_weights(self, samples, weights)
Unsparsify weights via least squares regression.
source code
 
_getFeatureIds(self)
Return ids of the used features
source code
 
_predict(self, data)
Predict the output for the provided data.
source code
 
getSensitivityAnalyzer(self, **kwargs)
Returns a sensitivity analyzer for SMLR.
source code

Inherited from base.Classifier: __repr__, __str__, clone, isTrained, predict, repredict, retrain, summary, train, trained, untrain

Inherited from base.Classifier (private): _postpredict, _posttrain, _prepredict, _pretrain, _regressionIsBogus, _setRetrainable

Inherited from misc.state.ClassWithCollections: __getattribute__, __new__, __setattr__, reset

Inherited from object: __delattr__, __format__, __hash__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _clf_internals = ['smlr', 'linear', 'has_sensitivity', 'binary...
Describes some specifics about the classifier -- is that it is doing regression for instance....
  lm = Parameter(.1, min= 1e-10, allowedtype= 'float', doc= """T...
  convergence_tol = Parameter(1e-3, min= 1e-10, max= 1.0, allowe...
  resamp_decay = Parameter(0.5, allowedtype= 'float', min= 0.0, ...
  min_resamp = Parameter(0.001, allowedtype= 'float', min= 1e-10...
  maxiter = Parameter(10000, allowedtype= 'int', min= 1, doc= ""...
  has_bias = Parameter(True, allowedtype= 'bool', doc= """Whethe...
  fit_all_weights = Parameter(True, allowedtype= 'bool', doc= ""...
  implementation = Parameter(_DEFAULT_IMPLEMENTATION, allowedtyp...
  seed = Parameter(None, allowedtype= 'None or int', doc= """See...
  unsparsify = Parameter(False, allowedtype= 'bool', doc= """***...
  std_to_keep = Parameter(2.0, allowedtype= 'float', doc= """Sta...
  biases = property(lambda self: self.__biases)
  weights = property(lambda self: self.__weights)

Inherited from base.Classifier: _DEV__doc__, feature_ids, predicting_time, predictions, regression, retrainable, trained_dataset, trained_labels, trained_nsamples, training_confusion, training_time, values

Inherited from misc.state.ClassWithCollections: descr

Instance Variables [hide private]
  __ulabels
Unigue labels from the training set.
  __weights_all
Contains all weights including bias values
  __weights
Just the weights, without the biases
  __biases
The biases, will remain none if has_bias is False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
Initialize an SMLR classifier.
Overrides: object.__init__

_train(self, dataset)

source code 
Train the classifier using dataset (Dataset).
Overrides: base.Classifier._train

_getFeatureIds(self)

source code 
Return ids of the used features
Overrides: base.Classifier._getFeatureIds

_predict(self, data)

source code 
Predict the output for the provided data.
Overrides: base.Classifier._predict

getSensitivityAnalyzer(self, **kwargs)

source code 
Returns a sensitivity analyzer for SMLR.
Overrides: base.Classifier.getSensitivityAnalyzer

Class Variable Details [hide private]

_clf_internals

Describes some specifics about the classifier -- is that it is doing regression for instance....
Value:
['smlr', 'linear', 'has_sensitivity', 'binary', 'multiclass', 'does_fe\
ature_selection']

lm

Value:
Parameter(.1, min= 1e-10, allowedtype= 'float', doc= """The penalty te\
rm lambda.  Larger values will give rise to
             more sparsification.""")

convergence_tol

Value:
Parameter(1e-3, min= 1e-10, max= 1.0, allowedtype= 'float', doc= """Wh\
en the weight change for each cycle drops below this value
             the regression is considered converged.  Smaller values
             lead to tighter convergence.""")

resamp_decay

Value:
Parameter(0.5, allowedtype= 'float', min= 0.0, max= 1.0, doc= """Decay\
 rate in the probability of resampling a zero weight.
             1.0 will immediately decrease to the min_resamp from 1.0,\
 0.0
             will never decrease from 1.0.""")

min_resamp

Value:
Parameter(0.001, allowedtype= 'float', min= 1e-10, max= 1.0, doc= "Min\
imum resampling probability for zeroed weights")

maxiter

Value:
Parameter(10000, allowedtype= 'int', min= 1, doc= """Maximum number of\
 iterations before stopping if not
             converged.""")

has_bias

Value:
Parameter(True, allowedtype= 'bool', doc= """Whether to add a bias ter\
m to allow fits to data not through
             zero""")

fit_all_weights

Value:
Parameter(True, allowedtype= 'bool', doc= """Whether to fit weights fo\
r all classes or to the number of
            classes minus one.  Both should give nearly identical resu\
lts, but
            if you set fit_all_weights to True it will take a little l\
onger
            and yield weights that are fully analyzable for each class\
.  Also,
...

implementation

Value:
Parameter(_DEFAULT_IMPLEMENTATION, allowedtype= 'basestring', choices=\
 ["C", "Python"], doc= """Use C or Python as the implementation of
             stepwise_regression. C version brings significant speedup\
 thus is
             the default one.""")

seed

Value:
Parameter(None, allowedtype= 'None or int', doc= """Seed to be used to\
 initialize random generator, might be
             used to replicate the run""")

unsparsify

Value:
Parameter(False, allowedtype= 'bool', doc= """***EXPERIMENTAL*** Wheth\
er to unsparsify the weights via
             regression. Note that it likely leads to worse classifier
             performance, but more interpretable weights.""")

std_to_keep

Value:
Parameter(2.0, allowedtype= 'float', doc= """Standard deviation thresh\
old of weights to keep when
             unsparsifying.""")