Naive Bayes Classifier Calculator

Apply Bayes' Theorem to classify a data point across two classes. Enter the prior probabilities P(Class 1) and P(Class 2), then provide up to three likelihoods P(Feature | Class) for each class. The calculator applies the Naive Bayes rule — multiplying likelihoods under the independence assumption — and returns the posterior probability for each class, plus the predicted class based on the highest posterior.

Prior probability of Class 1 before observing any features. P(Class 2) = 1 − P(Class 1) if you leave it blank.

Prior probability of Class 2. Should sum to 1 with P(Class 1).

Probability of Feature 1 occurring given Class 1.

Probability of Feature 1 occurring given Class 2.

Probability of Feature 2 occurring given Class 1. Set to 1 to ignore this feature.

Probability of Feature 2 occurring given Class 2. Set to 1 to ignore this feature.

Probability of Feature 3 occurring given Class 1. Set to 1 to ignore this feature.

Probability of Feature 3 occurring given Class 2. Set to 1 to ignore this feature.

Results

Predicted Class

--

Posterior P(Class 1 | Features)

--

Posterior P(Class 2 | Features)

--

Unnormalized Score — Class 1

--

Unnormalized Score — Class 2

--

Posterior Probability by Class

Results Table

Frequently Asked Questions

What is the Naive Bayes classifier?

Naive Bayes is a probabilistic classification algorithm based on Bayes' Theorem. It assumes that all features are conditionally independent of each other given the class label — hence the word 'naive'. Despite this simplifying assumption, it performs surprisingly well in many real-world tasks like spam filtering and text classification.

Why is it called 'naive'?

The algorithm is called 'naive' because it makes the strong assumption that every feature contributes independently to the probability of a class. In reality, features often correlate with each other. This assumption rarely holds perfectly, but it greatly simplifies computation and still yields competitive accuracy.

How does this calculator apply Bayes' Theorem?

The calculator computes an unnormalized score for each class as: P(Class) × P(Feature 1 | Class) × P(Feature 2 | Class) × P(Feature 3 | Class). It then normalizes these scores so the posteriors sum to 1, giving you P(Class | Features). The class with the higher posterior is the predicted class.

What should the prior probabilities sum to?

Ideally your entered P(Class 1) and P(Class 2) should sum to 1.0 (e.g. 0.4 and 0.6). The calculator normalizes them internally, so even if they don't sum exactly to 1, it will adjust. Think of priors as the fraction of each class in your training dataset.

What if I only have one or two features?

Set the likelihood inputs for unused features to 1.0 for both classes. Multiplying by 1.0 has no effect on the scores, effectively removing that feature from the calculation. The result will then reflect only the active features you've provided.

When can I use Naive Bayes in practice?

Naive Bayes works best when you have categorical or count-based features and a moderate amount of training data. It is widely used for spam detection, sentiment analysis, document categorization, and medical diagnosis. It can struggle when features are highly correlated or when continuous features don't follow a Gaussian distribution.

What is the difference between the unnormalized score and the posterior probability?

The unnormalized score is the raw product of the prior and all likelihoods: P(Class) × ΠP(Featureᵢ | Class). Because these scores don't sum to 1, they are normalized by dividing each by their total, producing the posterior probabilities that do sum to 1 and can be interpreted as true probabilities.

What are the types of Naive Bayes models?

The three most common types are Gaussian Naive Bayes (for continuous features assumed to follow a normal distribution), Multinomial Naive Bayes (for count data like word frequencies in text), and Bernoulli Naive Bayes (for binary features). This calculator implements the general discrete/probability version suitable for any feature likelihoods you supply.

More Statistics Tools