|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjml.classification.Classifier
jml.classification.MaxEnt
public class MaxEnt
A Java implementation for the maximum entropy modeling. We aim to maximize the log-likelihood of p(y_n|x_n) for {(x_n, y_n)|n = 1, 2, ..., N}, which can be written as L(X) = sum_n [log P(y_n|x_n)] / N.
Field Summary | |
---|---|
private org.apache.commons.math.linear.RealMatrix[] |
F
Feature matrix array. |
private static long |
serialVersionUID
|
Fields inherited from class jml.classification.Classifier |
---|
epsilon, IDLabelMap, labelIDs, labels, nClass, nExample, nFeature, W, X, Y |
Constructor Summary | |
---|---|
MaxEnt()
|
Method Summary | |
---|---|
void |
feedData(double[][][] data)
Feed features for this maximum entropy model. |
void |
feedData(org.apache.commons.math.linear.RealMatrix[] F)
Feed features for this maximum entropy model. |
void |
loadModel(java.lang.String filePath)
Load the model for a classifier. |
static void |
main(java.lang.String[] args)
|
int[] |
predict(double[][][] data)
Predict labels for the test data formated as a 3D double array. |
int[] |
predict(org.apache.commons.math.linear.RealMatrix[] Ft)
Predict labels for the test data formated as a 1D RealMatrix array. |
org.apache.commons.math.linear.RealMatrix |
predictLabelMatrix(double[][][] data)
Predict the label matrix given test data formated as a 3D double array. |
org.apache.commons.math.linear.RealMatrix |
predictLabelMatrix(org.apache.commons.math.linear.RealMatrix[] Ft)
Predict the label matrix given test data formated as a 1D RealMatrix array. |
org.apache.commons.math.linear.RealMatrix |
predictLabelScoreMatrix(double[][][] data)
Predict the label score matrix given test data formated as a 3D double array. |
org.apache.commons.math.linear.RealMatrix |
predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix Ft)
Predict the label score matrix given test data formated as an original data matrix. |
org.apache.commons.math.linear.RealMatrix |
predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix[] Ft)
Predict the label score matrix given test data formated as a RealMatrix array. |
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, predictLabelMatrix, predictLabelScoreMatrix |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private org.apache.commons.math.linear.RealMatrix[] F
Constructor Detail |
---|
public MaxEnt()
Method Detail |
---|
public static void main(java.lang.String[] args)
args
- public void feedData(double[][][] data)
data
- a 3D double
array, where data[n][i][k]
is the i-th feature value on the k-th class
for the n-th samplepublic void feedData(org.apache.commons.math.linear.RealMatrix[] F)
F
- a feature matrix array. F[n] is the feature
matrix for the n-th sample, where F[n][i][k]
is the i-th feature value on the k-th class
for the n-th samplepublic void train()
Classifier
train
in class Classifier
public int[] predict(double[][][] data)
double
array.
data
- a 3D double
array, where data[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
public int[] predict(org.apache.commons.math.linear.RealMatrix[] Ft)
RealMatrix
array.
Ft
- a feature matrix array. F[n] is the feature
matrix for the n-th sample, where F[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
public void loadModel(java.lang.String filePath)
Classifier
loadModel
in class Classifier
filePath
- file path to load the modelpublic void saveModel(java.lang.String filePath)
Classifier
saveModel
in class Classifier
filePath
- file path to save the modelpublic org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix Ft)
Classifier
predictLabelScoreMatrix
in class Classifier
Ft
- test data matrix with each column being a feature vector
public org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(org.apache.commons.math.linear.RealMatrix[] Ft)
RealMatrix
array.
Ft
- a feature matrix array. F[n] is the feature
matrix for the n-th sample, where F[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
public org.apache.commons.math.linear.RealMatrix predictLabelScoreMatrix(double[][][] data)
double
array.
data
- a 3D double
array, where data[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
public org.apache.commons.math.linear.RealMatrix predictLabelMatrix(org.apache.commons.math.linear.RealMatrix[] Ft)
RealMatrix
array.
Ft
- a feature matrix array. F[n] is the feature
matrix for the n-th sample, where F[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
public org.apache.commons.math.linear.RealMatrix predictLabelMatrix(double[][][] data)
double
array.
data
- a 3D double
array, where data[n][i][k]
is the i-th feature value on the k-th class
for the n-th sample
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |