Naive Bayes Classifier Demo illustration

Naive Bayes Classifier Demo

Naive Bayes classifies with Bayes’ rule under one bold assumption: features are independent given the class. In spam-filter mode, type any message and a built-in vocabulary of word counts scores it word by word — each bar is a log-likelihood ratio pushing toward spam or ham, stacking with the prior into the final verdict, while the Laplace smoothing α and the spam prior are yours to drag; words outside the vocabulary are listed as skipped. In Gaussian mode the same idea runs on 2D points you can click in: each class gets an axis-aligned mean/variance ellipse and the posterior colours the plane. Load the correlated preset to watch the independence assumption fail — the ellipses cannot tilt with the data.

Runs 100% in your browser — models are trained and computed locally on your device.

Notes

  • The posterior is proportional to prior × Π P(wordᵢ | class); each word contributes log P(w|spam) − log P(w|ham), so evidence adds up as bars.
  • Laplace smoothing replaces counts c with (c + α)/(N + αV), so unseen words never zero out a whole class.
  • Gaussian naive Bayes fits one variance per feature per class, giving axis-aligned ellipses that cannot represent correlated features — tilted data breaks the model.
  • Despite the wrong independence assumption, naive Bayes often classifies well: it only needs the argmax of the posterior right, not the probabilities themselves.
  • Runs 100% in your browser — models are trained and computed locally on your device.