Package opennlp.tools.ml.model
Class AbstractModel
java.lang.Object
opennlp.tools.ml.model.AbstractModel
- All Implemented Interfaces:
MaxentModel
- Direct Known Subclasses:
GISModel
,NaiveBayesModel
,PerceptronModel
,QNModel
A basic
MaxentModel
implementation.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionAbstractModel
(Context[] params, String[] predLabels, String[] outcomeNames) Initializes anAbstractModel
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
final String
getAllOutcomes
(double[] ocs) Retrieves a string matching all the outcome names with all the probabilities produced by theMaxentModel.eval(String[])
method.final String
getBestOutcome
(double[] ocs) Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.final Object[]
Provides the fundamental data structures which encode the maxent model information.int
Retrieves the index associated with the String name of the given outcome.int
final String
getOutcome
(int i) Retrieves the String name of the outcome associated with the indexi
.int
hashCode()
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface opennlp.tools.ml.model.MaxentModel
eval, eval, eval
-
Constructor Details
-
AbstractModel
Initializes anAbstractModel
.- Parameters:
params
- Theparameters
to set.predLabels
- The predicted labels.outcomeNames
- The names of the outcomes.
-
-
Method Details
-
getBestOutcome
Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.- Specified by:
getBestOutcome
in interfaceMaxentModel
- Parameters:
ocs
- A double[] as returned by the eval(String[] context) method.- Returns:
- The name of the most likely outcome.
-
getModelType
- Returns:
- Retrieves the
AbstractModel.ModelType
.
-
getAllOutcomes
Retrieves a string matching all the outcome names with all the probabilities produced by theMaxentModel.eval(String[])
method.- Specified by:
getAllOutcomes
in interfaceMaxentModel
- Parameters:
ocs
- Adouble[]
as returned by theMaxentModel.eval(String[])
method.- Returns:
- String containing outcome names paired with the normalized
probability (contained in the
double[] ocs
) for each one.
-
getOutcome
Description copied from interface:MaxentModel
Retrieves the String name of the outcome associated with the indexi
.- Specified by:
getOutcome
in interfaceMaxentModel
- Parameters:
i
- An outcome id.- Returns:
- Retrieves the name of the outcome associated with that id.
-
getIndex
Description copied from interface:MaxentModel
Retrieves the index associated with the String name of the given outcome.- Specified by:
getIndex
in interfaceMaxentModel
- Parameters:
outcome
- The String name of the outcome for which the index is desired.- Returns:
- Retrieves the index if the given
outcome
label exists for this model,-1
if it does not.
-
getNumOutcomes
public int getNumOutcomes()- Specified by:
getNumOutcomes
in interfaceMaxentModel
- Returns:
- Retrieves the number of outcomes for this model.
-
getDataStructures
Provides the fundamental data structures which encode the maxent model information. Note: This method will usually only be needed byGIS model writers
.The following values are held in the Object array which is returned by this method:
- Returns:
- An
Object
array with the values as described above.
-
hashCode
public int hashCode() -
equals
-