Gaussian Naive Bayes#

Gaussian Naive Bayes is a version of the Naive Bayes classifier for continuous features. It places a probability density function (PDF) over the features conditioned on a class basis and uses Bayes' Theorem to derive the final probabilities. In addition to the naive feature independence assumption, Gaussian Naive Bayes also assumes that all features are normally (Gaussian) distributed.

Interfaces: Estimator, Learner, Online, Probabilistic, Persistable

Data Type Compatibility: Continuous


# Name Default Type Description
1 priors null array The class prior probabilities as an associative array with class labels as keys and the prior probabilities as values. If null, then the learner will compute these values from the training data.


use Rubix\ML\Classifiers\GaussianNB;

$estimator = new GaussianNB([
    'benign' => 0.9,
    'malignant' => 0.1,

Additional Methods#

Return the class prior probabilities:

public priors() : float[]|null

Return the running mean of each feature column for each class:

public means() : array[]|null

Return the running variance of each feature column for each class:

public variances() : array[]|null


  • T. F. Chan et al. (1979). Updating Formulae and a Pairwise Algorithm for Computing Sample Variances.