Package opennlp.tools.ml.maxent.quasinewton

# Class QNTrainer

java.lang.Object
opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.maxent.quasinewton.QNTrainer

All Implemented Interfaces:
  `opennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>`, `opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters>`

public class QNTrainer extends opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
A Maxent model `trainer` using the L-BFGS algorithm.

See Also:
  - `AbstractEventTrainer`
  - `QNMinimizer`
  - `QNModel`
  - `Trainer`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final double`
  `L1COST_DEFAULT`
  The default L1-cost value is `0.1d`.
  `static final String`
  `L1COST_PARAM`
  `static final double`
  `L2COST_DEFAULT`
  The default L2-cost value is `0.1d`.
  `static final String`
  `L2COST_PARAM`
  `static final int`
  `M_DEFAULT`
  The default number of Hessian updates to store is `15`.
  `static final String`
  `M_PARAM`
  `static final int`
  `MAX_FCT_EVAL_DEFAULT`
  The default maximum number of function evaluations is `30,000`.
  `static final String`
  `MAX_FCT_EVAL_PARAM`
  `static final String`
  `MAXENT_QN_VALUE`
  `static final int`
  `THREADS_DEFAULT`
  `static final String`
  `THREADS_PARAM`

  ### Fields inherited from class opennlp.tools.ml.AbstractEventTrainer

  `DATA_INDEXER_ONE_PASS_REAL_VALUE, DATA_INDEXER_ONE_PASS_VALUE, DATA_INDEXER_PARAM, DATA_INDEXER_TWO_PASS_VALUE`

  ### Fields inherited from interface opennlp.tools.ml.EventTrainer

  `EVENT_VALUE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `QNTrainer()`
  Initializes a `QNTrainer`.
  `QNTrainer(int m)`
  Initializes a `QNTrainer` with the specified parameter `m`.
  `QNTrainer(int m, int maxFctEval)`
  Initializes a `QNTrainer` with the specified parameters.
  `QNTrainer(opennlp.tools.util.TrainingParameters parameters)`
  Initializes a `QNTrainer` with the specified `parameters`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `opennlp.tools.ml.model.AbstractModel`
  `doTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer)`
  `void`
  `init(opennlp.tools.util.TrainingParameters trainingParameters, Map<String,String> reportMap)`
  `boolean`
  `isSortAndMerge()`
  `QNModel`
  `trainModel(int iterations, opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer)`
  Trains a `model` using the QN algorithm.
  `void`
  `validate()`

  ### Methods inherited from class opennlp.tools.ml.AbstractEventTrainer

  `getDataIndexer, train, train`

  ### Methods inherited from class opennlp.tools.ml.AbstractTrainer

  `getAlgorithm, getCutoff, getIterations, getTrainingConfiguration, init`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface opennlp.tools.commons.Trainer

  `init`

- ## Field Details

  - ### MAXENT_QN_VALUE

    public static final String MAXENT_QN_VALUE
    See Also:
      - Constant Field Values

  - ### THREADS_PARAM

    public static final String THREADS_PARAM
    See Also:
      - Constant Field Values

  - ### THREADS_DEFAULT

    public static final int THREADS_DEFAULT
    See Also:
      - Constant Field Values

  - ### L1COST_PARAM

    public static final String L1COST_PARAM
    See Also:
      - Constant Field Values

  - ### L1COST_DEFAULT

    public static final double L1COST_DEFAULT
    The default L1-cost value is `0.1d`.
    See Also:
      - Constant Field Values

  - ### L2COST_PARAM

    public static final String L2COST_PARAM
    See Also:
      - Constant Field Values

  - ### L2COST_DEFAULT

    public static final double L2COST_DEFAULT
    The default L2-cost value is `0.1d`.
    See Also:
      - Constant Field Values

  - ### M_PARAM

    public static final String M_PARAM
    See Also:
      - Constant Field Values

  - ### M_DEFAULT

    public static final int M_DEFAULT
    The default number of Hessian updates to store is `15`.
    See Also:
      - Constant Field Values

  - ### MAX_FCT_EVAL_PARAM

    public static final String MAX_FCT_EVAL_PARAM
    See Also:
      - Constant Field Values

  - ### MAX_FCT_EVAL_DEFAULT

    public static final int MAX_FCT_EVAL_DEFAULT
    The default maximum number of function evaluations is `30,000`.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### QNTrainer

    public QNTrainer()
    Initializes a `QNTrainer`.

  - ### QNTrainer

    public QNTrainer(opennlp.tools.util.TrainingParameters parameters)
    Initializes a `QNTrainer` with the specified `parameters`.
    Parameters:
      `parameters` - The `TrainingParameters` to use.

  - ### QNTrainer

    public QNTrainer(int m)
    Initializes a `QNTrainer` with the specified parameter `m`.
    Parameters:
      `m` - The number of hessian updates to store.

  - ### QNTrainer

    public QNTrainer(int m, int maxFctEval)
    Initializes a `QNTrainer` with the specified parameters.
    Parameters:
      `m` - The number of hessian updates to store.

- ## Method Details

  - ### init

    public void init(opennlp.tools.util.TrainingParameters trainingParameters, Map<String,String> reportMap)
    Specified by:
      `init` in interface `opennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>`
    Overrides:
      `init` in class `opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>`

  - ### validate

    public void validate()
    Overrides:
      `validate` in class `opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>`

  - ### isSortAndMerge

    public boolean isSortAndMerge()
    Specified by:
      `isSortAndMerge` in class `opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>`

  - ### doTrain

    public opennlp.tools.ml.model.AbstractModel doTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) throws IOException
    Specified by:
      `doTrain` in class `opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>`
    Throws:
      `IOException`

  - ### trainModel

    public QNModel trainModel(int iterations, opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer)
    Trains a `model` using the QN algorithm.
    Parameters:
      `iterations` - The number of QN iterations to perform.
      `indexer` - The `DataIndexer` used to compress events in memory.
    Returns:
      A trained `QNModel` which can be used immediately or saved to disk using an `QNModelWriter`.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.