SPSS command: SPSS NAIVEBAYES

Naive Bayes classification in your browser

Naive Bayes classifies cases by combining each predictor's evidence under the assumption that predictors are independent within each class.

Free · No account · Files stay on your device · Updated 18 October 2026

What it tells you

Crosstabs runs SPSS NAIVEBAYES on your device: scale predictors are cut into equal-width bins, probabilities are smoothed, partially missing predictors are kept, and forward selection can pick the best subset by pseudo-BIC or a held-out test sample.

  • How many cases the model classifies correctly, overall and per class, in the training and optional test samples.
  • Each class's prior probability and, for every predictor category or bin, its conditional probability given the class.
  • Which predictors earn their place, from the forward-selection sequence and its pseudo-BIC or test criterion.

When to use it

Use it when

  • Many categorical survey answers used to predict a categorical outcome, such as renewal, churn or preferred brand.
  • You want a fast, transparent classifier whose probability tables can be read directly.
  • Predictors have scattered missing values and you do not want to drop whole cases.

Use something else when

  • Predictors are strongly related to each other (several items measuring the same thing): the independence assumption double-counts their evidence.
  • You need effect sizes or significance tests for predictors: use logistic or multinomial logistic regression.
  • A scale target: Naive Bayes needs a categorical target; use KNN or regression for numeric prediction.
  • Case weights must be applied: the panel ignores them and notes this.

How to run it in Crosstabs

  1. 01

    Open your data

    Open the file in the workspace and switch to Statistics mode.

  2. 02

    Choose Naive Bayes

    In the Machine learning group, pick Naive Bayes.

  3. 03

    Set the target and predictors

    Under Variables choose the Target, any Categorical predictors and Scale predictors (binned), and set Equal-width bins for scale predictors (10 by default).

  4. 04

    Choose predictor selection

    Under Predictor selection keep Use all predictors, or choose Select the best subset (maximum number of predictors) or Select an exact number of predictors.

  5. 05

    Hold out a test sample and run

    Optionally tick Hold out a test sample and set Training sample (%) and Random seed; with a test sample, subset selection uses the test criterion instead of the pseudo-BIC. Click Run.

Worked example

Computed by the Crosstabs engine from the synthetic data below when this page was built — not typed in.

Data

240 synthetic subscribers with a renewal outcome (Renewed or Lapsed). Two predictors carry signal — number of support tickets (none, some, many) and monthly usage hours, a scale predictor cut into 10 equal-width bins — and two are pure noise: region and age. Generated from a fixed seed; all cases are training cases.

Predictor Selection Summary
StepPredictor addedAverage log-likelihood (training)Pseudo-BIC
1usage−0.49190.5033
2support−0.46220.4850
3age−0.44950.4838
4region−0.45090.4966

Selected predictors: usage, support, age. Smaller criterion values indicate better subsets.

Prior Probabilities
CategoryProbability
Lapsed0.4208
Renewed0.5792
Classification — Training
ObservedLapsedRenewedPercent Correct
Lapsed673466.3%
Renewed2511482.0%
Overall Percent38.3%61.7%75.4%

Probabilities use Dirichlet smoothing of 1/N.

Conditional Probabilities: support
CategoryLapsedRenewed
many0.46530.1727
none0.23760.5467
some0.29700.2806

How to read it

Forward selection added predictors in the order usage, support, age, region, and the pseudo-BIC kept 3: usage, support, age. With those, the model classifies 75.4% of the training cases correctly, against a prior of 57.9% for the larger class. The pseudo-BIC also kept age, which is pure noise in this file — a reminder that selection on training data alone can overfit. Without a test sample this is an optimistic in-sample figure; tick Hold out a test sample for an honest estimate.

Output tables explained

Predictor Selection Summary
Each step's added predictor, the average training log-likelihood and the pseudo-BIC or test criterion; the smallest criterion marks the chosen subset.
Classification
Observed by predicted counts, percent correct per class and overall percent, for training and, if held out, test cases.
Prior Probabilities
The smoothed share of each target class in the training data.
Conditional Probabilities
One table per selected predictor: the probability of each category or bin within each class. Large differences across a row are what drive classification.

Assumptions and notes

  • Predictors are conditionally independent given the class; the classifier often still ranks cases well when this is only roughly true.
  • Scale predictors are discretised into equal-width bins over the training data, with empty bins merged.
  • Probabilities use Dirichlet smoothing of 1/N, so an unseen category never gets probability zero.
  • A missing predictor value is skipped for that case only; predictors with fewer than two observed categories are ignored.

How the results are validated

Posterior probabilities match scikit-learn CategoricalNB (alpha = 1/N) on complete cases to 12 decimal places. An independent NumPy implementation checks the equal-width binning with empty-bin merging, the handling of missing predictors, the priors and the forward-selection sequence under both the pseudo-BIC and the test-data criterion, with log-likelihoods and criteria agreeing to 12 decimals and the same predictors selected. Validation evidence

Questions

How are scale predictors handled?

They are cut into the number of Equal-width bins you set (10 by default) over the training data, and empty bins are merged with their neighbours. Fewer bins give smoother, more stable probabilities on small samples.

What is the pseudo-BIC?

Without a test sample, each step of the forward sequence is scored by the negative average training log-likelihood plus a penalty that grows with the number of predictors, ½·p·ln N / N; the step with the smallest value sets the subset. With a test sample, the criterion is the negative average log-likelihood of the test cases instead.

Why is the training accuracy optimistic?

The model is scored on the same cases that estimated its probabilities. Tick Hold out a test sample to get a classification table on cases the model has not seen.

Can Naive Bayes use cases with missing predictors?

Yes. Unlike KNN or MIXED, which drop the case, Naive Bayes simply skips the missing predictor for that case and uses the others.

Is my data uploaded?

No. Binning, selection and classification run in your browser and the file stays on your device.

Run Naive Bayes on your own data

Open a .sav, CSV or Excel file. Everything runs in your browser; the file never leaves your device.

Open the workspace

SPSS is a trademark of IBM Corp. Crosstabs is not affiliated with or endorsed by IBM.