Package opennlp.tools.ml.perceptron
Class SimplePerceptronSequenceTrainer
java.lang.Object
opennlp.tools.ml.AbstractTrainer
opennlp.tools.ml.AbstractEventModelSequenceTrainer
opennlp.tools.ml.perceptron.SimplePerceptronSequenceTrainer
- All Implemented Interfaces:
Trainer
,EventModelSequenceTrainer<Event>
Trains
models
with sequences using the perceptron algorithm.
Each outcome is represented as a binary perceptron classifier. This supports standard (integer) weighting as well average weighting.
Sequence information is used in a simplified was to that described in: Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with the Perceptron Algorithm. Michael Collins, EMNLP 2002.
Specifically only updates are applied to tokens which were incorrectly tagged by a sequence tagger rather than to all feature across the sequence which differ from the training sequence.
-
Field Summary
Fields inherited from interface opennlp.tools.ml.EventModelSequenceTrainer
SEQUENCE_VALUE
-
Constructor Summary
ConstructorDescriptionInstantiates aSimplePerceptronSequenceTrainer
with a default configuration of training parameters. -
Method Summary
Modifier and TypeMethodDescriptiondoTrain
(SequenceStream<Event> events) void
nextIteration
(int iteration) trainModel
(int iterations, SequenceStream<Event> sequenceStream, int cutoff, boolean useAverage) Trains aPerceptronModel
with given parameters.void
validate()
Checks the configuredparameters
.Methods inherited from class opennlp.tools.ml.AbstractEventModelSequenceTrainer
train
Methods inherited from class opennlp.tools.ml.AbstractTrainer
getAlgorithm, getCutoff, getIterations, init
-
Field Details
-
PERCEPTRON_SEQUENCE_VALUE
- See Also:
-
-
Constructor Details
-
SimplePerceptronSequenceTrainer
public SimplePerceptronSequenceTrainer()Instantiates aSimplePerceptronSequenceTrainer
with a default configuration of training parameters.
-
-
Method Details
-
validate
public void validate()Checks the configuredparameters
. If a subclass overrides this, it should callsuper.validate();
.- Overrides:
validate
in classAbstractTrainer
- Throws:
IllegalArgumentException
- Thrown if the algorithm name is not equal to {PERCEPTRON_SEQUENCE_VALUE
}.
-
doTrain
- Specified by:
doTrain
in classAbstractEventModelSequenceTrainer
- Throws:
IOException
-
trainModel
public AbstractModel trainModel(int iterations, SequenceStream<Event> sequenceStream, int cutoff, boolean useAverage) throws IOException Trains aPerceptronModel
with given parameters.- Parameters:
iterations
- The number of iterations to use for training.sequenceStream
- TheSequenceStream<Event>
used as data input.cutoff
- The {TrainingParameters.CUTOFF_PARAM
} value to use for training.useAverage
- Whether to use 'averaging', or not.- Returns:
- A valid, trained
perceptron model
. - Throws:
IOException
-
nextIteration
- Throws:
IOException
-