Package opennlp.tools.ml.naivebayes

## Class NaiveBayesModel

- java.lang.Object
- - opennlp.tools.ml.model.AbstractModel
  - - opennlp.tools.ml.naivebayes.NaiveBayesModel

- All Implemented Interfaces:
    `MaxentModel`

      public class NaiveBayesModel
      extends AbstractModel

  A `MaxentModel` implementation of the multinomial Naive Bayes classifier model.
  See Also:
    `AbstractModel`, `MaxentModel`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class opennlp.tools.ml.model.AbstractModel

      `AbstractModel.ModelType`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NaiveBayesModel​(Context[] params, String[] predLabels, String[] outcomeNames)` | Initializes a `NaiveBayesModel`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static double[]` | `eval​(int[] context, double[] prior, EvalParameters model)` | Evaluates a `NaiveBayesModel`.
    `double[]` | `eval​(String[] context)` | Evaluates a `context`.
    `double[]` | `eval​(String[] context, double[] probs)` | Evaluates a `context`.
    `double[]` | `eval​(String[] context, float[] values)` | Evaluates a `context` with the specified context `values`.
    `double[]` | `eval​(String[] context, float[] values, double[] outsums)` |

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

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

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

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

- - ### Constructor Detail

    - #### NaiveBayesModel

          public NaiveBayesModel​(Context[] params,
                                 String[] predLabels,
                                 String[] outcomeNames)

      Initializes a `NaiveBayesModel`.
      Parameters:
        `params` - The `parameters` to set.
        `predLabels` - The predicted labels.
        `outcomeNames` - The names of the outcomes.

  - ### Method Detail

    - #### eval

          public double[] eval​(String[] context)

      Evaluates a `context`.
      Parameters:
        `context` - An array of String names of the contextual predicates which are to be evaluated together.
      Returns:
        An array of the probabilities for each of the different outcomes, all of which sum to `1`.

    - #### eval

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

      Evaluates a `context` with the specified context `values`.
      Parameters:
        `context` - An array of String names of the contextual predicates which are to be evaluated together.
        `values` - The values associated with each context.
      Returns:
        An array of the probabilities for each of the different outcomes, all of which sum to `1`.

    - #### eval

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

      Evaluates a `context`.
      Parameters:
        `context` - An array of String names of the contextual predicates which are to be evaluated together.
        `probs` - An array which is populated with the probabilities for each of the different outcomes, all of which sum to 1.
      Returns:
        An array of the probabilities for each of the different outcomes, all of which sum to `1`.

    - #### eval

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

    - #### eval

          public static double[] eval​(int[] context,
                                      double[] prior,
                                      EvalParameters model)

      Evaluates a `NaiveBayesModel`.
      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[]`.