# Detecting Spam using Machine Learning

The most online tutorials like to use a simple example to introduce to machine learning by classify unknown text in spam or not spam. They say that this is a binary-class problem. But why is this a binary-class problem? I think it is a one-class problem! I do only need positive samples of my inbox to learn what is not spam. If I do take a bunch of not spam textes as positiv samples and a bunch of spam-mails as negativ samples, then of course it's possible to train a binary-classifier and make predictions from unlabeled data, but where is the difference to the onc-class-approach? There I would just define a training-set of all non spam examples and train some one-class classifier. What do you think?

Strictly speaking, "one class classification" does not make sense as an idea. If there is only one possible state of a predicted value, then there is no prediction problem. The answer is always the single class.

Concretely, if you only have spam examples, you would always achieve 100% accuracy by classifying all email as spam. This is clearly wrong, and the only way to know how it is wrong is to know where the classification is wrong -- where emails are not in the spam class.

So-called one-class classification techniques are really anomaly detection approaches. They have an implicit assumption that things unlike the examples are not part of the single class, but, this is just an assumption about data being probably not within the class. There's a binary classification problem lurking in there.

What is wrong with a binary classifier?

• hello sean, thank u for ur reply. there is actually no problem with a binary classifier. I'm just wondering what kind of classification is right for the mentioned problem. Oct 31, 2014 at 17:58

The problem arises if you want to classify a new example as either spam or not spam. A one-class method will only give you some score of how well a new instance fits to this class, but how do you turn this into a binary prediction without knowing how big the score would be for the other class?

If you look at the Naive Bayes classifier it essentially trains a "one-class" model for each class and arrives at a prediction by choosing the class with the highest score. But this requires you to have training examples for all classes.