Spectral Regression Discriminant Analysis (SRDA)

Described in [Cai08].

class mlpy.Srda(alpha=1.0)

Spectral Regression Discriminant Analysis (SRDA).

Example:

>>> from numpy import *
>>> from mlpy import *
>>> xtr = array([[1.0, 2.0, 3.1, 1.0],  # first sample
...              [1.0, 2.0, 3.0, 2.0],  # second sample
...              [1.0, 2.0, 3.2, 1.0]]) # third sample
>>> ytr = array([1, -1, 1])             # classes
>>> mysrda = Srda()                     # initialize srda class
>>> mysrda.compute(xtr, ytr)            # compute srda
1                                      
>>> mysrda.predict(xtr)                 # predict srda model on training data
array([ 1, -1,  1])
>>> xts = array([4.0, 5.0, 6.0, 7.0])   # test point
>>> mysrda.predict(xts)                 # predict srda model on test point
-1
>>> mysrda.realpred                     # real-valued prediction
-16.500000000001439
>>> mysrda.weights(xtr, ytr)            # compute weights on training data
array([  1.00000000e+00,   2.00000000e+00,   5.40012479e-13,
         4.50000000e+00])

Initialize the Srda class.

Input

  • alpha - [float] (>=0.0) regularization parameter
compute(x, y)

Compute Srda model.

Initialize array of alphas a.

Input

  • x - [2D numpy array float] (sample x feature) training data
  • y - [1D numpy array integer] (two classes) classes

Output

  • 1
predict(p)

Predict Srda model on test point(s).

Input

  • p - test point(s) [1D or 2D numpy array float]

Output

  • cl - [integer or 1D numpy array integer] class(es) predicted
  • self.realpred - [float or 1D numpy array float] real valued prediction
weights(x, y)

Return feature weights.

Input

  • x - [2D numpy array float] (sample x feature) training data
  • y - [1D numpy array integer] (two classes) classes

Output

  • fw - [1D numpy array float] feature weights
[Cai08]D Cai, X He, J Han. SRDA: An Efficient Algorithm for Large-Scale Discriminant Analysis. Knowledge and Data Engineering, IEEE Transactions on Volume 20, Issue 1, Jan. 2008 Page(s):1 - 12.

Previous topic

Fisher Discriminant Analysis (FDA)

Next topic

Penalized Discriminant Analysis (PDA)

This Page