Class PerceptronTrainer
- Namespace
- NOpenNLP.Tools.Ml.Perceptron
- Assembly
- NOpenNLP.Tools.dll
Trains models using the perceptron algorithm. Each outcome is represented as a binary perceptron classifier. This supports standard (integer) weighting as well as average weighting as described in: Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with the Perceptron Algorithm. Michael Collins, EMNLP 2002.
public class PerceptronTrainer : AbstractEventTrainer, IEventTrainer
- Inheritance
-
PerceptronTrainer
- Implements
- Inherited Members
Constructors
PerceptronTrainer()
public PerceptronTrainer()
PerceptronTrainer(TrainingParameters)
public PerceptronTrainer(TrainingParameters parameters)
Parameters
parametersTrainingParameters
Fields
PERCEPTRON_VALUE
public const string PERCEPTRON_VALUE = "PERCEPTRON"
Field Value
TOLERANCE_DEFAULT
public const double TOLERANCE_DEFAULT = 1E-05
Field Value
Properties
IsSortAndMerge
Whether the data indexer should sort and merge the indexed events.
public override bool IsSortAndMerge { get; }
Property Value
SkippedAveraging
Enables skipped averaging; this flag changes the standard averaging to special averaging instead.
If we are doing averaging, and the current iteration is one of the first 20 or it is a perfect square, then update the summed parameters.
The reason we don't take all of them is that the parameters change less toward the end of training, so they drown out the contributions of the more volatile early iterations. The use of perfect squares allows us to sample from successively farther apart iterations.
public virtual bool SkippedAveraging { set; }
Property Value
StepSizeDecrease
Enables and sets step size decrease. The step size is decreased every iteration by the specified value, in percent.
public virtual double StepSizeDecrease { set; }
Property Value
Tolerance
Specifies the tolerance. If the change in training set accuracy is less than this, stop iterating.
public virtual double Tolerance { set; }
Property Value
Methods
DoTrain(IDataIndexer)
Trains a model from the given, already indexed, training data.
public override IMaxentModel DoTrain(IDataIndexer indexer)
Parameters
indexerIDataIndexer
Returns
TrainModel(int, IDataIndexer, int)
public virtual AbstractModel TrainModel(int iterations, IDataIndexer di, int cutoff)
Parameters
iterationsintdiIDataIndexercutoffint
Returns
TrainModel(int, IDataIndexer, int, bool)
public virtual AbstractModel TrainModel(int iterations, IDataIndexer di, int cutoff, bool useAverage)
Parameters
iterationsintdiIDataIndexercutoffintuseAveragebool
Returns
Validate()
Checks the parameters. If a subclass overrides this, it should call the base implementation.
public override void Validate()
Exceptions
- ArgumentException
Thrown if a parameter is not valid.