public class MaxEntShell extends Object
Modifier and Type | Method and Description |
---|---|
static Classification[] |
classify(Classifier classifier,
Iterator<Instance> data)
Compute the maxent classifications for unlabeled instances given
by an iterator.
|
static Classification |
classify(Classifier classifier,
String[] features)
Compute the maxent classification of an instance.
|
static Classification[] |
classify(Classifier classifier,
String[][] features)
Compute the maxent classifications of an array of instances
|
static Classifier |
load(File modelFile)
Load a classifier from a file.
|
static void |
main(String[] args)
Command-line wrapper to train, test, or run a maxent
classifier.
|
static double |
test(Classifier classifier,
Iterator<Instance> data)
Test a maxent classifier.
|
static double |
test(Classifier classifier,
String[][] features,
String[] labels)
Test a maxent classifier.
|
static Classifier |
train(Iterator<Instance> data,
double var,
File save)
Train a maxent classifier.
|
static Classifier |
train(String[][] features,
String[] labels,
double var,
File save)
Train a maxent classifier.
|
public static Classifier train(String[][] features, String[] labels, double var, File save) throws IOException
features
represents the features of a training instance. The label for
that instance is in the corresponding position of
labels
.features
- Each row gives the on features of an instancelabels
- Each position gives the label of an instancevar
- Gaussian prior variance for trainingsave
- if non-null, save the trained model to this fileIOException
- if the trained model cannot be savedpublic static Classifier train(Iterator<Instance> data, double var, File save) throws IOException
data
returns
training instances with a TokenSequence
as data and a
target object. The tokens in the instance data will be converted to
features.data
- the iterator over training instancesvar
- Gaussian prior variance for training.save
- if non-null, save the trained model to this fileIOException
- if the trained model cannot be savedpublic static double test(Classifier classifier, String[][] features, String[] labels)
classifier
- the classifier to testfeatures
- an array of instances represented as arrays of featureslabels
- corresponding labelspublic static double test(Classifier classifier, Iterator<Instance> data)
classifier
- the classifier to testdata
- an iterator over labeled instancespublic static Classification classify(Classifier classifier, String[] features)
classifier
- the classifierfeatures
- the features that are on for this instancepublic static Classification[] classify(Classifier classifier, String[][] features)
classifier
- the classifierfeatures
- each row represents the on features for an instancepublic static Classification[] classify(Classifier classifier, Iterator<Instance> data)
classifier
- the classifierdata
- the iterator over unlabeled instancespublic static Classifier load(File modelFile) throws IOException, ClassNotFoundException
modelFile
- the fileIOException
- if the file cannot be opened or readClassNotFoundException
- if the file does not deserializepublic static void main(String[] args) throws Exception
args
- the command line arguments. Options (shell and Java quoting should be added as needed):
--help
booleantrue
for longer documentation. Default is false
.--prefix-code
Java-code--gaussian-variance
positive-number--train
filenane--test
filename--classify
filename--model
filenameException
- if an error occursCopyright © 2016. All rights reserved.