|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcalhoun.analysis.crf.Conrad
public class Conrad
the central class for the Conrad engine. Has a main function for calling Conrad
from the command line and a high-level public interface for programmatic operations. This class
is mostly just a container which delegates the real work to the various objects set up in the
configuration.
| Constructor Summary | |
|---|---|
Conrad()
creates a Conrad engine with no configuration. |
|
Conrad(java.lang.String configFile)
creates a Conrad engine based on configuration information from an XML model file. |
|
| Method Summary | |
|---|---|
java.lang.String |
getFeatureName(int index)
looks up a feature's name given it's index |
CRFInference |
getInference()
returns the configured inference algorithm which will be used to predict hidden states for new inputs once the model is trained. |
InputHandler |
getInputHandler()
returns the configured input handler. |
ModelManager |
getModel()
returns the configured ModelManager object. |
int |
getNumFeatures()
returns the number of individual features in the model. |
int |
getNumStates()
returns the number of hidden states in the model |
CRFTraining |
getOptimizer()
returns the configured numerical optimizer which will be used to select the optimal feature weights during training. |
OutputHandler |
getOutputHandler()
gets the configured output handler. |
java.lang.String |
getStateName(int state)
looks up the name of a state given it's index. |
double |
getTrainingTime()
returns the the total number of seconds used in training. |
double[] |
getWeights()
returns the feature weights. |
static void |
main(java.lang.String[] args)
Command line entry point for running CRFs. |
CRFInference.InferenceResult |
predict(InputSequence data)
preforms inference on the input sequence and determines the best labeling for the sequence using the configured inference algorithm. |
java.lang.String |
printWeights()
Returns a formatted string listing the weights. |
static Conrad |
read(java.lang.String filename)
read in a Conrad engine from a file. |
void |
setInference(CRFInference inference)
sets the inference algorithm. |
void |
setInputHandler(InputHandler inputHandler)
sets the configured input handler. |
void |
setModel(ModelManager model)
sets the model. |
void |
setOptimizer(CRFTraining optimizer)
sets the numerical optimizer. |
void |
setOutputHandler(OutputHandler outputHandler)
sets the configured output handler. |
void |
setWeights(double[] weights)
sets feature weights. |
void |
test(java.util.List<? extends TrainingSequence<?>> data)
|
void |
test(java.util.List<? extends TrainingSequence<?>> data,
java.lang.String location)
runs a trained model against a set of input data with known results and evaluates the performance. |
void |
test(java.lang.String inputLocation)
runs a trained model against a set of input data with known results and evaluates the performance. |
void |
test(java.lang.String inputLocation,
java.lang.String outputLocation)
|
void |
testWithoutAnswers(java.lang.String inputLocation,
java.lang.String outputLocation)
|
void |
train(java.util.List<? extends TrainingSequence<?>> data)
fully trains this Conrad engine with this training data. |
void |
train(java.lang.String location)
fully trains this Conrad engine with this training data. |
void |
trainFeatures(java.util.List<? extends TrainingSequence<?>> data)
trains only the features in the current model with this training data. |
void |
trainFeatures(java.lang.String location)
trains only the features in the current model with this training data. |
void |
trainWeights(java.util.List<? extends TrainingSequence<?>> data)
optimizes the feature weights for the current model with this training data. |
void |
trainWeights(java.lang.String location)
optimizes the feature weights for the current model with this training data. |
void |
write(java.lang.String filename)
writes this Conrad engine to a file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Conrad()
public Conrad(java.lang.String configFile)
configFile - string filename of the XML model file| Method Detail |
|---|
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - list of command line arguments. See usage for details.
java.lang.Exception
public void write(java.lang.String filename)
throws java.io.IOException
filename - string name of the file that will contain the serialized model.
java.io.IOException - if a problem occurs writing to the file
public static Conrad read(java.lang.String filename)
throws java.io.IOException
write(java.lang.String)
filename - string name of the file containing the model.
java.io.IOException - if there is a problem reading the file
public void train(java.lang.String location)
throws java.io.IOException
InputHandler is responsible for converting into a list of training sequences
of the appropriate type.
location - string location of the data. The exact meaning will be determined by the InputHandler.
java.io.IOException - if there is a problem reading the training data.public void train(java.util.List<? extends TrainingSequence<?>> data)
data - a list of training sequences to use for training
public void trainFeatures(java.lang.String location)
throws java.io.IOException
FeatureManager.train(int, calhoun.analysis.crf.ModelManager, java.util.List extends calhoun.analysis.crf.io.TrainingSequence extends InputType>>) is called
for each feature in the model, but no optimization is performed and no feature weights are set. This allows the
features themselves to be parameterized on one set of training data, while using a different set for optimizing the
feature weights.
The training data is specified as a string location,
which the configured InputHandler is responsible for converting into a list of training sequences
of the appropriate type.
location - string location of the data. The exact meaning will be determined by the InputHandler.
java.io.IOException - if there is a problem reading the training datapublic void trainFeatures(java.util.List<? extends TrainingSequence<?>> data)
FeatureManager.train(int, calhoun.analysis.crf.ModelManager, java.util.List extends calhoun.analysis.crf.io.TrainingSequence extends InputType>>) is called
for each feature in the model, but no optimization is performed and no feature weights are set. This allows the
features themselves to be parameterized on one set of training data, while using a different set for optimizing the
feature weights.The training data is specified as a list of training sequences, and no DataInputHandler is used.
data - a list of training sequences to use for training
public void trainWeights(java.lang.String location)
throws java.io.IOException
trainFeatures(java.lang.String)
has already been called to train the individual features. The training data is specified as a list of training sequences, and no DataInputHandler is used.
location - string location of the data. The exact meaning will be determined by the InputHandler.
java.io.IOException - if there is a problem reading the training datapublic void trainWeights(java.util.List<? extends TrainingSequence<?>> data)
trainFeatures(java.lang.String)
has already been called to train the individual features. The training data is specified as a list of training sequences, and no DataInputHandler is used.
data - a list of training sequences to use for training
public void test(java.lang.String inputLocation)
throws java.io.IOException
train(java.lang.String) has already been called to train the model. For convenience, the data is passed in as a training set,
although the model is not trained. The input is used to create a set of predictions and then those predictions are
compared against the expected outputs. The result of the prediction is passed to the output handler which can compare
the predicted versus the expected values
inputLocation - string location of the data. The exact meaning will be determined by the InputHandler.
java.io.IOException - if there is a problem reading the training data
public void test(java.lang.String inputLocation,
java.lang.String outputLocation)
throws java.io.IOException
java.io.IOException
public void test(java.util.List<? extends TrainingSequence<?>> data)
throws java.io.IOException
java.io.IOException
public void testWithoutAnswers(java.lang.String inputLocation,
java.lang.String outputLocation)
throws java.io.IOException
java.io.IOException
public void test(java.util.List<? extends TrainingSequence<?>> data,
java.lang.String location)
throws java.io.IOException
train(java.lang.String) has already been called to train the model. For convenience, the data is passed in as a training set,
although the model is not trained. The input is used to create a set of predictions and then those predictions are
compared against the expected outputs. The result of the prediction is passed to the output handler which can compare
the predicted versus the expected values
data - a list of training sequences to use for training
java.io.IOExceptionpublic CRFInference.InferenceResult predict(InputSequence data)
data - the input sequence the engine will use for inference
public void setWeights(double[] weights)
weights - an array of doubles containing one weight for each feature.public java.lang.String getFeatureName(int index)
index - index of the feature
public double getTrainingTime()
public int getNumFeatures()
FeatureManagers because each
FeatureManager may have 0, 1, or many features associated with it.
public int getNumStates()
public java.lang.String getStateName(int state)
public ModelManager getModel()
public CRFTraining getOptimizer()
public double[] getWeights()
getNumFeatures()public CRFInference getInference()
public void setInference(CRFInference inference)
public void setModel(ModelManager model)
public void setOptimizer(CRFTraining optimizer)
public java.lang.String printWeights()
public InputHandler getInputHandler()
public void setInputHandler(InputHandler inputHandler)
inputHandler - the input handler for this modelpublic OutputHandler getOutputHandler()
public void setOutputHandler(OutputHandler outputHandler)
outputHandler - the output handler for this model
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||