Package ai.sklearn4j.naive_bayes
Class BernoulliNaiveBayes
- java.lang.Object
-
- ai.sklearn4j.base.ClassifierMixin
-
- ai.sklearn4j.naive_bayes.BaseNaiveBayes
-
- ai.sklearn4j.naive_bayes.BernoulliNaiveBayes
-
public class BernoulliNaiveBayes extends BaseNaiveBayes
Naive Bayes classifier for bernoulli distributed models.
-
-
Field Summary
-
Fields inherited from class ai.sklearn4j.base.ClassifierMixin
classCounts, classes
-
-
Constructor Summary
Constructors Constructor Description BernoulliNaiveBayes()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetBinarizationThreshold()Gets the threshold for binarizing (mapping to booleans) of sample features.NumpyArray<Double>getClassLogPrior()Gets the log probability of each class (smoothed).NumpyArray<Double>getFeatureCounts()Gets the number of samples encountered for each (class, feature) during fitting.NumpyArray<Double>getFeatureLogProbabilities()Gets the empirical log probability of features given a class, P(x_i|y).protected NumpyArray<Double>jointLogLikelihood(NumpyArray<Double> x)Compute the unnormalized posterior log probability of X.voidsetBinarizationThreshold(double binarizationThreshold)Sets the threshold for binarizing (mapping to booleans) of sample features.voidsetClassLogPrior(NumpyArray<Double> classLogPrior)Sets the log probability of each class (smoothed).voidsetFeatureCount(NumpyArray<Double> featureCounts)Sets the number of samples encountered for each (class, feature) during fitting.voidsetFeatureLogProbabilities(NumpyArray<Double> featureLogProbabilities)Sets the empirical log probability of features given a class, P(x_i|y).-
Methods inherited from class ai.sklearn4j.naive_bayes.BaseNaiveBayes
predict, predictLogProbabilities, predictProbabilities
-
Methods inherited from class ai.sklearn4j.base.ClassifierMixin
getClassCounts, getClasses, getFeatureNamesIn, getNumberOfFeatures, setClassCounts, setClasses, setFeatureNamesIn, setNumberOfFeatures
-
-
-
-
Method Detail
-
jointLogLikelihood
protected NumpyArray<Double> jointLogLikelihood(NumpyArray<Double> x)
Compute the unnormalized posterior log probability of X.I.e. ``log P(c) + log P(x|c)`` for all rows x of X, as an array-like of shape (n_samples, n_classes).
predict, predictProbabilities, and predictLogProbabilities pass the input over to jointLogLikelihood.
- Specified by:
jointLogLikelihoodin classBaseNaiveBayes- Parameters:
x- An array-like of shape (n_samples, n_classes).- Returns:
- The unnormalized posterior log probability of X.
-
getFeatureLogProbabilities
public NumpyArray<Double> getFeatureLogProbabilities()
Gets the empirical log probability of features given a class, P(x_i|y).- Returns:
- Empirical log probability of features given a class, P(x_i|y).
-
setFeatureLogProbabilities
public void setFeatureLogProbabilities(NumpyArray<Double> featureLogProbabilities)
Sets the empirical log probability of features given a class, P(x_i|y).- Parameters:
featureLogProbabilities- The empirical log probability of features given a class, P(x_i|y).
-
getClassLogPrior
public NumpyArray<Double> getClassLogPrior()
Gets the log probability of each class (smoothed).- Returns:
- Log probability of each class (smoothed).
-
setClassLogPrior
public void setClassLogPrior(NumpyArray<Double> classLogPrior)
Sets the log probability of each class (smoothed).- Parameters:
classLogPrior- The log probability of each class (smoothed).
-
getFeatureCounts
public NumpyArray<Double> getFeatureCounts()
Gets the number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided.- Returns:
- Number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided.
-
setFeatureCount
public void setFeatureCount(NumpyArray<Double> featureCounts)
Sets the number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided.- Parameters:
featureCounts- The number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided.
-
getBinarizationThreshold
public double getBinarizationThreshold()
Gets the threshold for binarizing (mapping to booleans) of sample features. If None, input is presumed to already consist of binary vectors.- Returns:
- Threshold for binarizing (mapping to booleans) of sample features. If None, input is presumed to already consist of binary vectors.
-
setBinarizationThreshold
public void setBinarizationThreshold(double binarizationThreshold)
Sets the threshold for binarizing (mapping to booleans) of sample features. If None, input is presumed to already consist of binary vectors.- Parameters:
binarizationThreshold- The threshold for binarizing (mapping to booleans) of sample features. If None, input is presumed to already consist of binary vectors.
-
-