Package opennlp.tools.ml.perceptron
Class PerceptronModel
- java.lang.Object
-
- opennlp.tools.ml.model.AbstractModel
-
- opennlp.tools.ml.perceptron.PerceptronModel
-
- All Implemented Interfaces:
MaxentModel
public class PerceptronModel extends AbstractModel
Amodelimplementation 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opennlp.tools.ml.model.AbstractModel
AbstractModel.ModelType
-
-
Constructor Summary
Constructors Constructor Description PerceptronModel(Context[] params, String[] predLabels, String[] outcomeNames)Initializes aPerceptronModel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static double[]eval(int[] context, double[] prior, EvalParameters model)Evaluates aPerceptronModel.double[]eval(String[] context)Evaluates acontext.double[]eval(String[] context, double[] probs)Evaluates acontext.double[]eval(String[] context, float[] values)Evaluates acontextwith the specified contextvalues.double[]eval(String[] context, float[] values, double[] outsums)inthashCode()-
Methods inherited from class opennlp.tools.ml.model.AbstractModel
getAllOutcomes, getBestOutcome, getDataStructures, getIndex, getModelType, getNumOutcomes, getOutcome
-
-
-
-
Constructor Detail
-
PerceptronModel
public PerceptronModel(Context[] params, String[] predLabels, String[] outcomeNames)
Initializes aPerceptronModel.- Parameters:
params- Theparametersto set.predLabels- The predicted labels.outcomeNames- The names of the outcomes.
-
-
Method Detail
-
eval
public double[] eval(String[] context)
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
public double[] eval(String[] context, float[] values)
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
public double[] eval(String[] context, double[] probs)
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
public double[] eval(String[] context, float[] values, double[] outsums)
-
eval
public static double[] eval(int[] context, double[] prior, EvalParameters model)Evaluates aPerceptronModel.- Parameters:
context- The context parameters asint[].prior- The data prior to the evaluation asdouble[].model- TheEvalParametersused for evaluation.- Returns:
- The resulting evaluation data as
double[].
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractModel
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classAbstractModel
-
-