Class GISTrainer
An implementation of Generalized Iterative Scaling. The reference paper
for this implementation was Adwait Ratnaparkhi's tech report at the
University of Pennsylvania's Institute for Research in Cognitive Science,
and is available at ftp://ftp.cis.upenn.edu/pub/ircs/tr/97-08.ps.Z.
The slack parameter used in the above implementation has been removed by default
from the computation and a method for updating with Gaussian smoothing has been
added per Investigating GIS and Smoothing for Maximum Entropy Taggers, Clark and Curran (2002).
http://acl.ldc.upenn.edu/E/E03/E03-1071.pdf
Gaussian smoothing can be used by setting useGaussianSmoothing to true.
A prior can be used to train models which converge to the distribution which minimizes the relative entropy between the distribution specified by the empirical constraints of the training data and the specified prior. By default, the uniform distribution is used as the prior.
public class GISTrainer : AbstractEventTrainer, IEventTrainer
- Inheritance
-
GISTrainer
- Implements
- Inherited Members
Constructors
GISTrainer()
Creates a new GISTrainer instance which does not print progress messages about training to the console.
public GISTrainer()
Fields
LOG_LIKELIHOOD_THRESHOLD_DEFAULT
public const double LOG_LIKELIHOOD_THRESHOLD_DEFAULT = 0.0001
Field Value
LOG_LIKELIHOOD_THRESHOLD_PARAM
public const string LOG_LIKELIHOOD_THRESHOLD_PARAM = "LLThreshold"
Field Value
MAXENT_VALUE
public const string MAXENT_VALUE = "MAXENT"
Field Value
OLD_LL_THRESHOLD_PARAM
[Obsolete("Use LOG_LIKELIHOOD_THRESHOLD_PARAM instead.")]
public const string OLD_LL_THRESHOLD_PARAM = "llthreshold"
Field Value
Properties
GaussianSigma
Turns on Gaussian smoothing and sets its sigma value.
public virtual double GaussianSigma { set; }
Property Value
IsSortAndMerge
Whether the data indexer should sort and merge the indexed events.
public override bool IsSortAndMerge { get; }
Property Value
Smoothing
Sets whether this trainer will use smoothing while training the model. This can improve model accuracy, though training will potentially take longer and use more memory. Model size will also be larger.
public virtual bool Smoothing { set; }
Property Value
SmoothingObservation
Sets the "number" of times we want the trainer to imagine it saw a feature that it actually didn't see.
public virtual double SmoothingObservation { 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
Init(TrainingParameters, IDictionary<string, string>?)
Initializes this trainer with the given parameters and report map.
public override void Init(TrainingParameters trainingParameters, IDictionary<string, string>? reportMap)
Parameters
trainingParametersTrainingParametersreportMapIDictionary<string, string>
TrainModel(IObjectStream<Event?>)
Trains a model using the GIS algorithm, assuming 100 iterations and no cutoff.
public virtual GISModel TrainModel(IObjectStream<Event?> eventStream)
Parameters
eventStreamIObjectStream<Event>The event stream holding the data on which this model will be trained.
Returns
- GISModel
The newly trained model, which can be used immediately or saved to disk using a GISModelWriter.
TrainModel(IObjectStream<Event?>, int, int)
Trains a GIS model on the events in the specified event stream, using the specified number of iterations and the specified count cutoff.
public virtual GISModel TrainModel(IObjectStream<Event?> eventStream, int iterations, int cutoff)
Parameters
eventStreamIObjectStream<Event>A stream of all events.
iterationsintThe number of iterations to use for GIS.
cutoffintThe number of times a feature must occur to be included.
Returns
- GISModel
A GIS model trained with the specified parameters.
TrainModel(int, IDataIndexer)
Trains a model using the GIS algorithm.
public virtual GISModel TrainModel(int iterations, IDataIndexer di)
Parameters
iterationsintThe number of GIS iterations to perform.
diIDataIndexerThe data indexer used to compress events in memory.
Returns
TrainModel(int, IDataIndexer, IPrior, int)
Trains a model using the GIS algorithm.
public virtual GISModel TrainModel(int iterations, IDataIndexer di, IPrior modelPrior, int threads)
Parameters
iterationsintThe number of GIS iterations to perform.
diIDataIndexerThe data indexer used to compress events in memory.
modelPriorIPriorThe prior distribution used to train this model.
threadsintThe number of threads to compute model expectations with.
Returns
TrainModel(int, IDataIndexer, int)
Trains a model using the GIS algorithm.
public virtual GISModel TrainModel(int iterations, IDataIndexer di, int threads)
Parameters
iterationsintThe number of GIS iterations to perform.
diIDataIndexerThe data indexer used to compress events in memory.
threadsintThe number of threads to compute model expectations with.