MGMLaboratory
Back

Menu

01Home
02About Us
03Projects
04Publications
05Member
06Articles
07Contact

Let's Talk

Open in Mail app

Socials

Malang (ID) --:--Privacy PolicyTerms of Service

February 26, 20171 min read

Naive Bayes Beats Nearest Neighbour on Short Messy TextNaive Bayes Beats Nearest Neighbour on Short Messy Text

Two simple classifiers, one clear gap, and a lesson about how much labelling is enough.

  • Conference
  • Publications

Written by

  • SRShirasaka RenIT & Infrastructure · Student Member

In this article

  1. 01How they differed in practice
  2. 02What to take from the comparison

Choosing a classifier for a small mobile task is rarely about the state of the art. It is about what runs fast, trains on a modest sample, and behaves predictably. A 2017 study on spam detection in tweets offers a clean example of that trade.

A phone in use. Image: Océanos y dados, CC0, via Wikimedia Commons.
Fig. 01A phone in use. Image: Océanos y dados, CC0, via Wikimedia Commons.

Two classifiers went head to head on the same job. Naive Bayes estimates the probability that a tweet belongs to a class from the words it contains. Nearest neighbour skips the probabilities and compares a new tweet against the labelled examples it most resembles.

01/02

How they differed in practice

The neighbour approach used a weighting scheme that gives rare words more influence, which suits short messages where common words carry little signal. Even with that help it trailed Naive Bayes by eleven percentage points.

  • Naive Bayes: 82 percent accuracy and simple to retrain.
  • Nearest neighbour: 71 percent, with more tuning required.
A spam message in a mailbox. Image: Pavouk, CC BY-SA 4.0, via Wikimedia Commons.
Fig. 02A spam message in a mailbox. Image: Pavouk, CC BY-SA 4.0, via Wikimedia Commons.

02/02

What to take from the comparison

Accuracy climbed as more labelled examples were added, and the study tested training sets from ten tweets up to a hundred. That curve matters more than any single figure, because it tells a team how much labelling work to budget.

The other lesson is about preprocessing. Cleaning, tokenising, and stemming the text before training did part of the work that a heavier model would otherwise have to do.

None of this is settled science. Both classifiers were tested on one hundred Indonesian tweets, so the ranking could move with a different language or platform. The durable outcome is the method: label a small set, compare two simple models, and ship the one that holds up.

Source

  1. Pinandito et al. (2017). Spam Detection Framework for Android Twitter Application Using Naive Bayes and K-Nearest Neighbor Classifiers. Proceedings of the 2017 International Conference on Software and Computer Applications.

    DOI10.1145/3056662.3056704 (opens in a new tab)

Next articleFiltering Spam Out of a Twitter Timeline on Android(Keep scrolling)(Read it next)(Loading)