Class QNModel
java.lang.Object
opennlp.tools.ml.model.AbstractModel
opennlp.tools.ml.maxent.quasinewton.QNModel
- All Implemented Interfaces:
MaxentModel
A
maximum entropy model which has been trained via the
L-BFGS algorithm ,
which belongs to the group of Quasi Newton (QN) algorithms.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractModel
AbstractModel.ModelType -
Field Summary
Fields inherited from class AbstractModel
evalParams, modelType, outcomeNames, pmap, prior -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static double[]eval(int[] context, float[] values, double[] probs, int nOutcomes, int nPredLabels, double[] parameters) Evaluates which should be used during training to report model accuracy.double[]Evaluates acontext.double[]Evaluates acontext.double[]Evaluates acontextwith the specified contextvalues.private double[]Evaluates which should be used during inference.intprivate ContextgetPredIndex(String predicate) Methods inherited from class AbstractModel
equals, getAllOutcomes, getBestOutcome, getDataStructures, getIndex, getModelType, getOutcome, hashCode
-
Constructor Details
-
QNModel
Initializes aQNModelwith the specified parameters, predicate/feature labels, and outcome names.- Parameters:
params- Theparametersof the model.predLabels- The names of the predicates used in this model.outcomeNames- The names of the outcomes this model predicts.
-
-
Method Details
-
getNumOutcomes
public int getNumOutcomes()- Specified by:
getNumOutcomesin interfaceMaxentModel- Overrides:
getNumOutcomesin classAbstractModel- Returns:
- Retrieves the number of outcomes for this model.
-
getPredIndex
-
eval
Evaluates acontext.- 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
Evaluates acontext.- 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
Evaluates acontextwith the specified contextvalues.- 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
Evaluates which should be used during inference.- Parameters:
context- The predicates which have been observed at the present decision point.values- The weights of the predicates which have been observed at the present decision point.probs- The probability for outcomes.- Returns:
- Normalized probabilities for the outcomes given the context.
-
eval
static double[] eval(int[] context, float[] values, double[] probs, int nOutcomes, int nPredLabels, double[] parameters) Evaluates which should be used during training to report model accuracy.- Parameters:
context- The indices of the predicates which have been observed at the present decision point.values- The weights of the predicates which have been observed at the present decision point.probs- The probability for outcomes.nOutcomes- The number of outcomes.nPredLabels- The number of unique predicates.parameters- The model parameters.- Returns:
- Normalized probabilities for the outcomes given the context.
-