jml.classification
Class AdaBoost

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

public class AdaBoost
extends Classifier

A Java implementation for AdaBoost.

Version:
1.0, Oct. 20th, 2013
Author:
Mingjie Qian
See Also:
Serialized Form

Field Summary
(package private)  double[] alphas
          Weights on the outputs of the trained weak classifiers.
private static long serialVersionUID
           
(package private)  int T
          Number of iterations, or the number of weak classifiers.
(package private)  Classifier[] weakClassifiers
          The sequence of weak classifiers during training.
 
Fields inherited from class jml.classification.Classifier
epsilon, IDLabelMap, labelIDs, labels, nClass, nExample, nFeature, W, X, Y
 
Constructor Summary
AdaBoost()
          Default constructor.
AdaBoost(Classifier[] weakClassifiers)
          Constructor.
 
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 predictLabelMatrix(org.apache.commons.math.linear.RealMatrix Xt)
          Predict the label matrix given test data formated as an original data matrix.
 org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix Xt)
          Predict the label score matrix given test data formated as an original data matrix.
 void saveModel(java.lang.String filePath)
          Save the model for a classifier.
 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, 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

T

int T
Number of iterations, or the number of weak classifiers.


weakClassifiers

Classifier[] weakClassifiers
The sequence of weak classifiers during training.


alphas

double[] alphas
Weights on the outputs of the trained weak classifiers.

Constructor Detail

AdaBoost

public AdaBoost(Classifier[] weakClassifiers)
Constructor.

Parameters:
weakClassifiers - a sequence of weak classifiers to be trained during the boosting procedure

AdaBoost

public AdaBoost()
Default constructor.

Method Detail

main

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

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

train

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

Specified by:
train in class Classifier

predictLabelMatrix

public org.apache.commons.math.linear.RealMatrix predictLabelMatrix(org.apache.commons.math.linear.RealMatrix Xt)
Description copied from class: Classifier
Predict the label 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 subclasses need to implement this abstract method rather than to override it.

Overrides:
predictLabelMatrix in class Classifier
Parameters:
Xt - test data matrix with each column being a feature vector
Returns:
predicted N x K label matrix, where N is the number of test samples, and K is the number of classes

predictLabelScoreMatrix

public org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix Xt)
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:
Xt - 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