Skip to main content

GaussianNB

#include <Skigen/NaiveBayes>

template <typename Scalar = double>
class Skigen::GaussianNB(priors=VectorType(), var_smoothing=1e-9)

Gaussian Naive Bayes classifier.

Can perform online updates to model parameters via partial_fit. The likelihood of the features is assumed to be Gaussian:

P(xiy)=12πσy2exp ⁣((xiμy)22σy2)P(x_i | y) = \frac{1}{\sqrt{2\pi\sigma_y^2}} \exp\!\left(-\frac{(x_i-\mu_y)^2}{2\sigma_y^2}\right)

Mirrors sklearn.naive_bayes.GaussianNB.



Attributes:

  • class_count : const Eigen::VectorXi

  • class_prior : VectorType

  • classes : const Eigen::VectorXi

  • epsilon : Scalar

  • theta : MatrixType

  • var : MatrixType


Methods

fit(X, y)

Fit the model from scratch using a single training batch.


predict(X)

Predict labels for samples in X.


predict_proba(X)

Class probability estimates (n_samples × n_classes).


predict_log_proba(X)

Log of class probability estimates.


partial_fit(X, y, classes)

Incremental fit on a batch of samples.

On the first call, classes must be provided (the full set of expected classes). On subsequent calls, an empty classes vector indicates re-use of the previously discovered classes.