Beispiel #1
0
        /// <summary>
        /// Train a model using the GIS algorithm.
        /// </summary>
        /// <param name="eventStream">
        ///          The EventStream holding the data on which this model will be
        ///          trained. </param>
        /// <param name="iterations">
        ///          The number of GIS iterations to perform. </param>
        /// <param name="cutoff">
        ///          The number of times a feature must be seen in order to be relevant
        ///          for training. </param>
        /// <param name="smoothing">
        ///          Defines whether the created trainer will use smoothing while
        ///          training the model. </param>
        /// <param name="printMessagesWhileTraining">
        ///          Determines whether training status messages are written to STDOUT. </param>
        /// <returns> The newly trained model, which can be used immediately or saved to
        ///         disk using an opennlp.maxent.io.GISModelWriter object. </returns>
        public static GISModel trainModel(EventStream eventStream, int iterations, int cutoff, bool smoothing,
                                          bool printMessagesWhileTraining)
        {
            GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);

            trainer.Smoothing            = smoothing;
            trainer.SmoothingObservation = SMOOTHING_OBSERVATION;
            return(trainer.trainModel(eventStream, iterations, cutoff));
        }
Beispiel #2
0
        /// <summary>
        /// Train a model using the GIS algorithm.
        /// </summary>
        /// <param name="eventStream">
        ///          The EventStream holding the data on which this model will be
        ///          trained. </param>
        /// <param name="iterations">
        ///          The number of GIS iterations to perform. </param>
        /// <param name="cutoff">
        ///          The number of times a feature must be seen in order to be relevant
        ///          for training. </param>
        /// <param name="sigma">
        ///          The standard deviation for the gaussian smoother. </param>
        /// <returns> The newly trained model, which can be used immediately or saved to
        ///         disk using an opennlp.maxent.io.GISModelWriter object. </returns>
        public static GISModel trainModel(EventStream eventStream, int iterations, int cutoff, double sigma)
        {
            GISTrainer trainer = new GISTrainer(PRINT_MESSAGES);

            if (sigma > 0)
            {
                trainer.GaussianSigma = sigma;
            }
            return(trainer.trainModel(eventStream, iterations, cutoff));
        }
Beispiel #3
0
        /// <summary>
        /// Train a model using the GIS algorithm.
        /// </summary>
        /// <param name="iterations">
        ///          The number of GIS iterations to perform. </param>
        /// <param name="indexer">
        ///          The object which will be used for event compilation. </param>
        /// <param name="printMessagesWhileTraining">
        ///          Determines whether training status messages are written to STDOUT. </param>
        /// <param name="smoothing">
        ///          Defines whether the created trainer will use smoothing while
        ///          training the model. </param>
        /// <param name="modelPrior">
        ///          The prior distribution for the model. </param>
        /// <param name="cutoff">
        ///          The number of times a predicate must occur to be used in a model. </param>
        /// <returns> The newly trained model, which can be used immediately or saved to
        ///         disk using an opennlp.maxent.io.GISModelWriter object. </returns>
        public static GISModel trainModel(int iterations, DataIndexer indexer, bool printMessagesWhileTraining,
                                          bool smoothing, Prior modelPrior, int cutoff, int threads)
        {
            GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);

            trainer.Smoothing            = smoothing;
            trainer.SmoothingObservation = SMOOTHING_OBSERVATION;
            if (modelPrior == null)
            {
                modelPrior = new UniformPrior();
            }

            return(trainer.trainModel(iterations, indexer, modelPrior, cutoff, threads));
        }