Machine Learning

Naive Bayes — Fast Probabilistic Classification

See how naive Bayes classifies: fit Gaussian naive Bayes to 2D data and watch the class means, spreads and decision regions, or train a spam filter on your own messages and see exactly how much each word pushes the prediction, with Laplace smoothing.
Trained live in your browserInteractive

Decision regions

test accuracy 100.0%

Ellipses show 1σ (solid) and 2σ (dashed) of each class. They are always axis-aligned: naive Bayes assumes the features are independent.

Data

240

What the model learned

ClassPriorMean (x1, x2)Std (x1, x2)
00.361-0.496, -0.3940.178, 0.228
10.3000.473, -0.3720.195, 0.216
20.3390.017, 0.5050.230, 0.213

Train accuracy

98.3%

Test accuracy

100.0%

How to use this tool

  1. 1Choose Gaussian (numbers) or Text (word counts).
  2. 2Gaussian: pick a dataset and read the learned means, standard deviations and accuracy.
  3. 3Text: edit the labelled training messages, then type a message to classify.
  4. 4Read the posterior probabilities and the per-word evidence table.

Frequently asked questions

It assumes the features are independent given the class — for text, that each word appears independently. That is rarely true, but the classifier still works surprisingly well.

It adds α to every word count so that a word never seen in one class does not make that class impossible.

Yes. They match scikit-learn’s GaussianNB and MultinomialNB on the same data and tokens.

No. Everything is calculated in your browser; nothing you enter is sent to MuhammadLab.