Class NegLogLikelihood

java.lang.Object
opennlp.tools.ml.maxent.quasinewton.NegLogLikelihood
All Implemented Interfaces:
Function
Direct Known Subclasses:
ParallelNegLogLikelihood

public class NegLogLikelihood extends Object implements Function
Evaluates negative log-likelihood and its gradient from DataIndexer.
See Also:
  • Field Details

    • dimension

      protected final int dimension
    • numOutcomes

      protected final int numOutcomes
    • numFeatures

      protected final int numFeatures
    • numContexts

      protected final int numContexts
    • values

      protected final float[][] values
    • contexts

      protected final int[][] contexts
    • outcomeList

      protected final int[] outcomeList
    • numTimesEventsSeen

      protected final int[] numTimesEventsSeen
    • tempSums

      protected final double[] tempSums
    • expectation

      protected final double[] expectation
    • gradient

      protected final double[] gradient
  • Constructor Details

    • NegLogLikelihood

      public NegLogLikelihood(DataIndexer indexer)
      Parameters:
      indexer - The DataIndexer to use as input provider.
  • Method Details

    • getDimension

      public int getDimension()
      Specified by:
      getDimension in interface Function
      Returns:
      Retrieves the dimension value.
    • getInitialPoint

      public double[] getInitialPoint()
      Returns:
      Retrieves the initial point as double array.
    • valueAt

      public double valueAt(double[] x)
      Computes the negative log-likelihood.
      Specified by:
      valueAt in interface Function
      Parameters:
      x - The input.
      Returns:
      Returns the computed negative log-likelihood.
      Throws:
      IllegalArgumentException - Thrown if parameters were invalid.
    • gradientAt

      public double[] gradientAt(double[] x)
      Computes the gradient.
      Specified by:
      gradientAt in interface Function
      Parameters:
      x - The input.
      Returns:
      Returns the computed gradient.
      Throws:
      IllegalArgumentException - Thrown if parameters were invalid.
    • indexOf

      protected int indexOf(int outcomeId, int featureId)