Class ComplementNaiveBayes


  • public class ComplementNaiveBayes
    extends BaseNaiveBayes
    Naive Bayes classifier for complement distributed models.
    • Constructor Detail

      • ComplementNaiveBayes

        public ComplementNaiveBayes()
    • 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:
        jointLogLikelihood in class BaseNaiveBayes
        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.
      • getFeatureAll

        public NumpyArray<Double> getFeatureAll()
        Get the value of the feature_all_ field.
        Returns:
        The value of the feature_all_ field.
      • setFeatureAll

        public void setFeatureAll​(NumpyArray<Double> featureAll)
        Sets the value of the value of the feature_all_ field.
        Parameters:
        featureAll - The value of the feature_all_ field.