"Binary classification algorithms don't work on multiclass problems"
That's not true!
We can use a trick to split the dataset and train binary models.
Here is how it works 👇
As the name suggests binary classification works with two classes. Logistic regression and perceptron are the typical examples.
But what if we don't know any other methods and we face a multi-class classification problem?
We can apply a little trick.
By splitting the data, we will get multiple binary classification problems.
One vs All
Consider this:
You need to sort fruits on the table. You have Apples, Bananas, and Oranges. Instead of sorting all the fruits at once, you're going to do it one fruit at a time.
You start with Apples. You create two categories: Apples and Not Apples (Oranges Bananas).
After Apples, you go on to Bananas and do the same process. You will have two piles of fruits: Bananas and a mix of Apples and Oranges.
You repeat the process for all categories.
Do you notice what we did?
We transformed a multiclass classification problem into a binary task.
That's exactly how One vs All method works.
For 3 categories you train 3 models:
Model 1: Class 1 vs [Class 2 Class 3]
Model 2: Class 2 vs [Class 1 Class 3]
Model 3: Class 3 vs [Class 1 Class 2]
This way the algorithm learns to recognize one category against all the others, one at a time.
What happens with new data?
You trained the 'model on your fruits' and you get an apple. What happens?
Your 3 models will each give an output:
Apple Model: 'I'm 92% sure it's an Apple.'
Banana Model: 'I'm 5% sure this is a Banana.'
Orange Model: 'I'm 9% sure this is an Orange.'
From this output, you will choose the most confident result.
And that's how you can apply binary models to multiclass problems.
___
I hope you've found this Tweet helpful.
Like/Retweet for support and follow
@levikul09 for more Data Science content.
Thanks 😉