Package ai.sklearn4j.naive_bayes
Class CategoricalNaiveBayes
- java.lang.Object
-
- ai.sklearn4j.base.ClassifierMixin
-
- ai.sklearn4j.naive_bayes.BaseNaiveBayes
-
- ai.sklearn4j.naive_bayes.CategoricalNaiveBayes
-
public class CategoricalNaiveBayes extends BaseNaiveBayes
Naive Bayes classifier for categorical features.The categorical Naive Bayes classifier is suitable for classification with discrete features that are categorically distributed. The categories of each feature are drawn from a categorical distribution.
-
-
Field Summary
-
Fields inherited from class ai.sklearn4j.base.ClassifierMixin
classCounts, classes
-
-
Constructor Summary
Constructors Constructor Description CategoricalNaiveBayes()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NumpyArray<Double>getClassLogPrior()Gets the log probability of each class (smoothed).List<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.voidsetClassLogPrior(NumpyArray<Double> classLogPrior)Sets the log probability of each class (smoothed).voidsetFeatureLogProbabilities(List<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).
-
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).
-
getFeatureLogProbabilities
public List<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(List<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).
-
-