Package opennlp.tools.ml.naivebayes
Class Probabilities<T>
- java.lang.Object
-
- opennlp.tools.ml.naivebayes.Probabilities<T>
-
- Type Parameters:
T
- the label (category) class
- Direct Known Subclasses:
LogProbabilities
public abstract class Probabilities<T> extends Object
Class implementing the probability distribution over labels returned by a classifier.
-
-
Constructor Summary
Constructors Constructor Description Probabilities()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIn(T t, double probability, int count)
Compounds the existing probability mass on the label with the new probability passed in to the method.void
discardCountsBelow(double i)
Double
get(T t)
Returns the probability associated with a labelMap<T,Double>
getAll()
Returns the probabilities associated with all labelsdouble
getConfidence()
Returns the best confidence with which this set of probabilities has been calculated.Set<T>
getKeys()
Returns the probabilities associated with all labelsDouble
getLog(T t)
Returns the log probability associated with a labelT
getMax()
Returns the most likely labeldouble
getMaxValue()
Returns the probability of the most likely labelvoid
set(T t, double probability)
Assigns a probability to a label, discarding any previously assigned probability.void
set(T t, Probability<T> probability)
Assigns a probability to a label, discarding any previously assigned probability.void
setConfidence(double confidence)
Sets the best confidence with which this set of probabilities has been calculated.void
setIfLarger(T t, double probability)
Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.void
setLog(T t, double probability)
Assigns a log probability to a label, discarding any previously assigned probability.String
toString()
-
-
-
Method Detail
-
set
public void set(T t, double probability)
Assigns a probability to a label, discarding any previously assigned probability.- Parameters:
t
- the label to which the probability is being assignedprobability
- the probability to assign
-
set
public void set(T t, Probability<T> probability)
Assigns a probability to a label, discarding any previously assigned probability.- Parameters:
t
- the label to which the probability is being assignedprobability
- the probability to assign
-
setIfLarger
public void setIfLarger(T t, double probability)
Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.- Parameters:
t
- the label to which the probability is being assignedprobability
- the probability to assign
-
setLog
public void setLog(T t, double probability)
Assigns a log probability to a label, discarding any previously assigned probability.- Parameters:
t
- the label to which the log probability is being assignedprobability
- the log probability to assign
-
addIn
public void addIn(T t, double probability, int count)
Compounds the existing probability mass on the label with the new probability passed in to the method.- Parameters:
t
- the label whose probability mass is being updatedprobability
- the probability weight to addcount
- the amplifying factor for the probability compounding
-
get
public Double get(T t)
Returns the probability associated with a label- Parameters:
t
- the label whose probability needs to be returned- Returns:
- the probability associated with the label
-
getLog
public Double getLog(T t)
Returns the log probability associated with a label- Parameters:
t
- the label whose log probability needs to be returned- Returns:
- the log probability associated with the label
-
getKeys
public Set<T> getKeys()
Returns the probabilities associated with all labels- Returns:
- the HashMap of labels and their probabilities
-
getAll
public Map<T,Double> getAll()
Returns the probabilities associated with all labels- Returns:
- the HashMap of labels and their probabilities
-
getMax
public T getMax()
Returns the most likely label- Returns:
- the label that has the highest associated probability
-
getMaxValue
public double getMaxValue()
Returns the probability of the most likely label- Returns:
- the highest probability
-
discardCountsBelow
public void discardCountsBelow(double i)
-
getConfidence
public double getConfidence()
Returns the best confidence with which this set of probabilities has been calculated. This is a function of the amount of data that supports the assertion. It is also a measure of the accuracy of the estimator of the probability.- Returns:
- the best confidence of the probabilities
-
setConfidence
public void setConfidence(double confidence)
Sets the best confidence with which this set of probabilities has been calculated. This is a function of the amount of data that supports the assertion. It is also a measure of the accuracy of the estimator of the probability.- Parameters:
confidence
- the confidence in the probabilities
-
-