jml.classification
Class LogisticRegressionMCLBFGS

java.lang.Object
  extended by jml.classification.Classifier
      extended by jml.classification.LogisticRegressionMCLBFGS
All Implemented Interfaces:
java.io.Serializable

public class LogisticRegressionMCLBFGS
extends Classifier

Multi-class logistic regression by using limited-memory BFGS method.

We aim to minimize the cross-entropy error function defined by

E(W) = -ln{p(T|w1, w2,..., wK)} / N = -sum_n{sum_k{t_{nk}ln(v_nk)}} / N,

where \nabla E(W) = X * (V - T) / N and v_nk = P(C_k|x_n).

Version:
1.0 Jan. 10th, 2013
Author:
Mingjie Qian
See Also:
Serialized Form

Field Summary
(package private)  Model model
           
private static long serialVersionUID
           
 
Fields inherited from class jml.classification.Classifier
epsilon, IDLabelMap, labelIDs, labels, nClass, nExample, nFeature, W, X, Y
 
Constructor Summary
LogisticRegressionMCLBFGS()
           
LogisticRegressionMCLBFGS(double epsilon)
           
LogisticRegressionMCLBFGS(Options options)
           
 
Method Summary
 void loadModel(java.lang.String filePath)
          Load the model for a classifier.
static void main(java.lang.String[] args)
           
 org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix X)
          Predict the label score matrix given test data formated as an original data matrix.
static void run(java.lang.String[] args)
          Run this module with arguments in a String array.
 void saveModel(java.lang.String filePath)
          Save the model for a classifier.
 void saveModel2(java.lang.String filePath)
           
 void train()
          Train the classifier.
 
Methods inherited from class jml.classification.Classifier
calcNumClass, feedData, feedData, feedLabels, feedLabels, feedLabels, getAccuracy, getIDLabelMap, getLabelIDMap, getProjectionMatrix, getTrainingLabelMatrix, labelIndexArray2LabelMatrix, labelScoreMatrix2LabelIndexArray, predict, predict, predictLabelMatrix, predictLabelMatrix, predictLabelScoreMatrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

model

Model model
Constructor Detail

LogisticRegressionMCLBFGS

public LogisticRegressionMCLBFGS()

LogisticRegressionMCLBFGS

public LogisticRegressionMCLBFGS(double epsilon)

LogisticRegressionMCLBFGS

public LogisticRegressionMCLBFGS(Options options)
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

run

public static void run(java.lang.String[] args)
Run this module with arguments in a String array.

Parameters:
args - command line arguments

train

public void train()
Description copied from class: Classifier
Train the classifier.

Specified by:
train in class Classifier

predictLabelScoreMatrix

public org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix X)
Description copied from class: Classifier
Predict the label score matrix given test data formated as an original data matrix. Note that if a method of an abstract class is declared as abstract, it is implemented as an interface function in Java. Thus subclass needs to implement this abstract method rather than to override it.

Specified by:
predictLabelScoreMatrix in class Classifier
Parameters:
X - test data matrix with each column being a feature vector
Returns:
predicted N x K label score matrix, where N is the number of test samples, and K is the number of classes

loadModel

public void loadModel(java.lang.String filePath)
Description copied from class: Classifier
Load the model for a classifier.

Specified by:
loadModel in class Classifier
Parameters:
filePath - file path to load the model

saveModel

public void saveModel(java.lang.String filePath)
Description copied from class: Classifier
Save the model for a classifier.

Specified by:
saveModel in class Classifier
Parameters:
filePath - file path to save the model

saveModel2

public void saveModel2(java.lang.String filePath)