Naive Bayes Explained With a Support Ticket Example

Two sorting trays with example billing and technical support ticket slips on a plum desk.

A customer sends a support ticket that says “refund charge.” A support team wants to route it to Billing or Technical Support. A Naive Bayes classifier can make that choice using the categories of past tickets and the words each category tends to contain.

Naive Bayes is a family of classifiers that uses Bayes’ theorem to compare classes given the observed features. The “naive” assumption is that features are independent once the class is known. For text, this lets the model combine evidence from individual words using counts learned from labeled examples.

What the model learns from old tickets

Suppose the training inbox contains 12 Billing tickets and eight Technical tickets. Your class priors are 12 ÷ 20 = 0.60 for Billing and 8 ÷ 20 = 0.40 for Technical. The prior describes how frequent each category was before the model saw the new ticket.

Billing is 60 percent of the training tickets and Technical is 40 percent.
The 12 Billing and eight Technical tickets set the baseline probabilities.

To keep the arithmetic small, use a vocabulary of four words. The table counts occurrences, so a word appearing twice in one ticket contributes two. A real text model typically uses a much larger vocabulary.

WordBilling countTechnical count
refund61
charge51
login16
error04
Total1212

Score a new ticket in three steps

1. Smooth the word counts

With add-one smoothing, add one to the count for each word in each class. The denominator becomes the total word count plus the vocabulary size, or 12 + 4 = 16 for either class. In Billing, “refund” has probability 7/16 and “charge” has probability 6/16. In Technical, each has probability 2/16.

Smoothing also gives “error” a Billing probability of 1/16 even though it never appeared in the Billing training sample. Without smoothing, that zero would make the entire Billing score zero whenever “error” appeared.

2. Multiply the prior and the word probabilities

For “refund charge,” Billing scores 0.60 × 7/16 × 6/16 = 0.0984375. Technical scores 0.40 × 2/16 × 2/16 = 0.00625. Multinomial Naive Bayes uses a word’s contribution once for each occurrence, and implementations generally add log probabilities to avoid multiplying many tiny values.

3. Compare the class scores

Billing has the higher score, so the model sends the ticket there. Dividing the Billing score by the sum of both scores gives about 94% under this model. If the team wants to use that number as an estimate of real-world confidence, it should check calibration on held-out tickets.

For refund charge, Billing scores 0.0984375 and Technical scores 0.00625 before normalization.
The unnormalized class scores are compared on the same scale.

When the independence assumption matters

“Refund” and “charge” can appear together even after you know a ticket is about Billing. Treating them as separate evidence can make the model overly confident. A count model also loses word order. The messages “please refund” and “do not refund” share a strong cue even though the requests differ.

Test a few real cases with negation, quoted messages, and mixed topics. Adding short phrases as features may help in some cases. Compare that change against the original on the same splits so another change in the data does not explain the difference.

Which Naive Bayes variant fits your data?

VariantTypical inputExample
MultinomialNonnegative word countsNumber of times “refund” appears
BernoulliBinary indicatorsWhether “refund” appears at least once
GaussianContinuous measurementsResponse time or request duration

The support ticket calculation uses the multinomial variant. Bernoulli also models whether a feature is absent. Gaussian Naive Bayes models each continuous feature with a Gaussian distribution within each class. Scikit-learn guide to Naive Bayes variants.

Evaluate the routing decisions

Fit the vocabulary and classifier on training tickets. Hold out later tickets if you plan to deploy the model on future requests, and keep messages from the same thread together to avoid leaking near-duplicates across training and validation. How to choose a cross-validation split.

Compare against a majority-class baseline and logistic regression. Then look at how many Technical tickets were routed to Billing and how many Billing tickets went the other way. Those two mistakes may create different delays. How to read a confusion matrix and how logistic regression works.

Common questions

Can Naive Bayes handle more than two classes?

Yes. Add a prior and feature probabilities for each class, then compare all scores. A support team could add separate Account Access and Shipping categories if it has enough examples to evaluate both.

What happens when a ticket contains a completely new word?

With a fixed training vocabulary, the vectorizer typically ignores a new word that lacks a feature column. Smoothing applies to a feature already in the vocabulary that was unseen within a particular class.

Is the class with the largest prior always predicted?

No. The prior is one factor. Strong word evidence can favor a rarer class. If the message contains no recognized features, a count-based model can fall back to the class priors.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top