Package opennlp.tools.ml.naivebayes
Class LogProbabilities<T>
- java.lang.Object
-
- opennlp.tools.ml.naivebayes.Probabilities<T>
-
- opennlp.tools.ml.naivebayes.LogProbabilities<T>
-
- Type Parameters:
T- the label (category) class
public class LogProbabilities<T> extends Probabilities<T>
Class implementing the probability distribution over labels returned by a classifier as a log of probabilities.This is necessary because floating point precision in Java does not allow for high-accuracy representation of very low probabilities such as would occur in a text categorizer.
- See Also:
Probabilities
-
-
Constructor Summary
Constructors Constructor Description LogProbabilities()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIn(T t, double probability, int count)Compounds the existingprobabilitymass on the labeltwith the new probability passed in to the method.voiddiscardCountsBelow(double i)Doubleget(T t)Map<T,Double>getAll()DoublegetLog(T t)TgetMax()voidset(T t, double probability)Assigns aprobabilityto a labelt, discarding any previously assigned probability.voidset(T t, Probability<T> probability)Assigns aprobabilityto a labelt, discarding any previously assigned probability.voidsetIfLarger(T t, double probability)Assigns aprobabilityto a labelt, discarding any previously assigned probability, if the new probability is greater than the old one.voidsetLog(T t, double probability)Assigns a logprobabilityto a labelt, discarding any previously assigned probability.-
Methods inherited from class opennlp.tools.ml.naivebayes.Probabilities
getConfidence, getKeys, getMaxValue, setConfidence, toString
-
-
-
-
Method Detail
-
set
public void set(T t, double probability)
Assigns aprobabilityto a labelt, discarding any previously assigned probability.- Overrides:
setin classProbabilities<T>- Parameters:
t- The label to which the probability is being assigned.probability- The probability to assign.
-
set
public void set(T t, Probability<T> probability)
Assigns aprobabilityto a labelt, discarding any previously assigned probability.- Overrides:
setin classProbabilities<T>- Parameters:
t- The label to which the probability is being assigned.probability- TheProbabilityto assign.
-
setIfLarger
public void setIfLarger(T t, double probability)
Assigns aprobabilityto a labelt, discarding any previously assigned probability, if the new probability is greater than the old one.- Overrides:
setIfLargerin classProbabilities<T>- Parameters:
t- The label to which the probability is being assigned.probability- The probability to assign.
-
setLog
public void setLog(T t, double probability)
Assigns a logprobabilityto a labelt, discarding any previously assigned probability.- Overrides:
setLogin classProbabilities<T>- Parameters:
t- The label to which the log probability is being assigned.probability- The logprobabilityto assign.
-
addIn
public void addIn(T t, double probability, int count)
Compounds the existingprobabilitymass on the labeltwith the new probability passed in to the method.- Overrides:
addInin classProbabilities<T>- Parameters:
t- The label whoseprobabilitymass is being updated.probability- The probability weight to add.count- The amplifying factor for theprobabilitycompounding.
-
get
public Double get(T t)
- Overrides:
getin classProbabilities<T>- Parameters:
t- The label whose probability shall be returned.- Returns:
- Retrieves the probability associated with the label
t.
-
getLog
public Double getLog(T t)
- Overrides:
getLogin classProbabilities<T>- Parameters:
t- The label whose log probability shall be returned.- Returns:
- Retrieves the log probability associated with the label
t.
-
discardCountsBelow
public void discardCountsBelow(double i)
- Overrides:
discardCountsBelowin classProbabilities<T>
-
getAll
public Map<T,Double> getAll()
- Overrides:
getAllin classProbabilities<T>- Returns:
- Retrieves a
Mapof all labels and their probabilities.
-
getMax
public T getMax()
- Overrides:
getMaxin classProbabilities<T>- Returns:
- Retrieves the label that has the highest associated probability
-
-