📊 Naive Bayes
Gaussian probabilistic classifier
Accuracy: —
Points: 0
Add to class
Preset
Setup
Controls
Stats
Accuracy
Points
0
Classes
2
Status
Ready
Click the canvas to add a point to the selected class.
Info & Theory

A naive Bayes classifier picks the class with the highest posterior probability given a point's features, using Bayes' rule and one simplifying assumption.

Bayes' rule

P(c | x) ∝ P(c) · P(x | c). The class prior P(c) is the fraction of training points in class c; the likelihood P(x | c) says how well the point fits that class.

The "naive" assumption

Features are assumed conditionally independent given the class, so the joint likelihood factorises: P(x | c) = P(x₁ | c) · P(x₂ | c). It is rarely exactly true, yet the classifier is fast and works surprisingly well.

Gaussian model

For continuous features we fit a Gaussian per class per axis: P(xⱼ | c) = 𝒩(xⱼ; μ_{cj}, σ²_{cj}). Each class therefore has a mean and variance on each axis, estimated from its points. The shaded ellipse marks one standard deviation.

Decision boundary

The background colours every pixel by the argmax posterior class; the more confident the model, the stronger the shade. Because variances differ between classes the boundary is quadratic, not a straight line — that is the signature of Gaussian naive Bayes.

About this simulation

Written by MySimulator Team · Reviewed by MySimulator Editorial Review

Last updated: 5 July 2026

This simulation shows a Gaussian naive Bayes classifier learning to separate points into 2 or 3 classes. For each class it fits a mean and variance along the x- and y-axes from the points you provide, treating the two axes as conditionally independent given the class — the "naive" assumption. Every pixel is then coloured by whichever class has the highest posterior probability under Bayes' rule, with shading strength showing the model's confidence, while the live accuracy readout tracks how well the fitted model reclassifies its own training points.

🔬 What it shows

A decision surface built from per-class Gaussians. Each class gets a mean marker and a one-standard-deviation ellipse computed from its points; the coloured background is the argmax-posterior region for every pixel, and because each class can have its own variance the boundary between classes is a curve, not a straight line.

🎮 How to use

Choose a preset (2 blobs, 3 blobs, or Overlap) or click the canvas to drop your own points into the selected class using the class buttons. Use the Classes slider to switch between 2 and 3 categories, then press Fit model to recompute the Gaussians and decision boundary, Clear points to start empty, or Reset to reload the current preset.

💡 Did you know?

Naive Bayes assumes features are independent given the class even when they are not — for example, height and weight are correlated in reality — yet the classifier is often still accurate in practice, and its speed and simplicity are why it remains a common baseline for text and spam classification.

Frequently asked questions

What is a naive Bayes classifier?

A naive Bayes classifier assigns each point to the class with the highest posterior probability, computed from Bayes' rule as proportional to the class prior times the likelihood of the point's features under that class. It is called "naive" because it assumes the features are conditionally independent given the class, which simplifies the likelihood into a product of per-feature probabilities.

How does this simulation estimate the probabilities?

For each class it computes the mean and variance of the x-coordinates and y-coordinates of its points, then models each axis as an independent Gaussian distribution. The class prior is simply the fraction of all points that belong to that class. Multiplying the prior by the two Gaussian likelihoods gives the (unnormalised) posterior used to classify any location.

Why is the decision boundary curved instead of straight?

When classes have different variances, the Gaussian likelihood terms do not cancel out linearly, so the argmax-posterior boundary becomes a curve, typically shaped like a parabola or ellipse arc. This quadratic boundary is a hallmark of Gaussian naive Bayes and is visible in the simulation whenever the class spreads differ, such as in the Overlap preset.

What does the accuracy percentage mean?

After you press Fit model, the simulation reclassifies every training point using the fitted Gaussians and reports the fraction that land back in their original class. This is training accuracy, not accuracy on new unseen data, so it mainly indicates how well the current Gaussian model separates the classes you have drawn.

Can I add more than 3 classes or draw my own data?

The Classes slider supports 2 or 3 categories, and you can always click anywhere on the canvas to add a point to whichever class is selected in the class picker. This lets you build custom, possibly overlapping or oddly shaped distributions and see how the fitted Gaussians and decision boundary adapt after pressing Fit model.