Naive Bayes Probability Calculator
Calculate class probabilities for a Naive Bayes classifier given feature likelihoods.
About Naive Bayes Probability Calculator
Naive Bayes classification computes P(C|features) ∝ P(C) × Π P(fᵢ|C) for each class, then normalizes. The 'naive' assumption is that features are conditionally independent given the class, which greatly simplifies computation and works surprisingly well for text classification, spam filtering, and sentiment analysis.
Formula
Naive Bayes
P(C|f1,...,fn) = P(C) * product(P(fi|C)) / P(f1,...,fn)
- P(C)
- Prior probability of class C
- P(fi|C)
- Likelihood of feature i given class C
Worked example
With the default values below, Naive Bayes Probability Calculator returns P(Class 1 | features) of 0.939130. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Prior P(C₁)accepts 0–1
- 0.6
- Feature Likelihoods P(fᵢ|C₁)
- 0.8, 0.6, 0.9
- Feature Likelihoods P(fᵢ|C₂)
- 0.3, 0.7, 0.2
Results
- P(Class 1 | features)
- 0.939130
- P(Class 2 | features)
- 0.060870
- Predicted Class
- 1
Step by step
- 1Score C₁: prior × Π likelihoods= 0.25920000
- 2Score C₂: prior × Π likelihoods= 0.01680000
- 3Normalized P(C₁|features)= 0.939130
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Why is it called 'naive'?
It assumes all features are conditionally independent given the class — a strong and usually unrealistic assumption. Despite this, Naive Bayes often performs well in practice, especially for text classification where the feature space is very high-dimensional.
How do you handle zero probabilities?
Laplace smoothing (adding a small constant to all counts) prevents any likelihood from being exactly zero, which would otherwise zero out the entire product for that class.
