Package opennlp.tools.ml.perceptron

# Class PerceptronModel

java.lang.Object
opennlp.tools.ml.model.AbstractModel
opennlp.tools.ml.perceptron.PerceptronModel

All Implemented Interfaces:
  `opennlp.tools.ml.model.MaxentModel`

public class PerceptronModel extends opennlp.tools.ml.model.AbstractModel
A `model` implementation based one the perceptron algorithm.

Each outcome is represented as a binary perceptron classifier. This supports standard (integer) weighting as well average weighting as described in: Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with the Perceptron Algorithm. Michael Collins, EMNLP 2002.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PerceptronModel(opennlp.tools.ml.model.Context[] params, String[] predLabels, String[] outcomeNames)`
  Initializes a `PerceptronModel`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `static double[]`
  `eval(int[] context, double[] prior, opennlp.tools.ml.model.EvalParameters model)`
  Evaluates a `PerceptronModel`.
  `double[]`
  `eval(String[] context)`
  `double[]`
  `eval(String[] context, double[] probs)`
  `double[]`
  `eval(String[] context, float[] values)`
  `double[]`
  `eval(String[] context, float[] values, double[] outsums)`
  `int`
  `hashCode()`

  ### Methods inherited from class opennlp.tools.ml.model.AbstractModel

  `getAllOutcomes, getBestOutcome, getDataStructures, getIndex, getModelType, getNumOutcomes, getOutcome`

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

  `getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PerceptronModel

    public PerceptronModel(opennlp.tools.ml.model.Context[] params, String[] predLabels, String[] outcomeNames)
    Initializes a `PerceptronModel`.
    Parameters:
      `params` - The `parameters` to set.
      `predLabels` - The predicted labels.
      `outcomeNames` - The names of the outcomes.

- ## Method Details

  - ### eval

    public double[] eval(String[] context)

  - ### eval

    public double[] eval(String[] context, float[] values)

  - ### eval

    public double[] eval(String[] context, double[] probs)

  - ### eval

    public double[] eval(String[] context, float[] values, double[] outsums)

  - ### eval

    public static double[] eval(int[] context, double[] prior, opennlp.tools.ml.model.EvalParameters model)
    Evaluates a `PerceptronModel`.
    Parameters:
      `context` - The context parameters as `int[]`.
      `prior` - The data prior to the evaluation as `double[]`.
      `model` - The `EvalParameters` used for evaluation.
    Returns:
      The resulting evaluation data as `double[]`.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `opennlp.tools.ml.model.AbstractModel`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `opennlp.tools.ml.model.AbstractModel`