Multi-Class Classification
Multi-Class Classification is a type of classification where a machine learning model chooses between more than two possible classes.
Multi-Class Classification means choosing one class from more than two possible classes.
The model learns patterns from labeled training data and then predicts which one of several possible categories a new input belongs to.
What Does "Multi-Class" Mean?
In Binary Classification, the model chooses between exactly two classes.
In Multi-Class Classification, there are more than two possible classes.
The model must choose one class from these possible categories.
Simple Example — Animal Classification
Imagine that we want to identify an animal from an image.
The model may have these possible classes:
Suppose we provide a new image to the model.
How Does Multi-Class Classification Work?
The model learns from training examples where the correct class is already known.
Unlike Binary Classification, the model has more than two possible answers.
Example — Fruit Classification
Suppose we want a model to identify different types of fruit.
Suppose the model receives information about a new fruit such as its weight, color, size, and shape.
The model chooses one class from the available fruit categories.
Binary vs Multi-Class Classification
The easiest way to understand Multi-Class Classification is to compare it with Binary Classification.
Example: Spam / Not Spam
Example: Cat / Dog / Horse / Bird
Example — Handwritten Digit Recognition
Another useful example is recognizing handwritten numbers.
Suppose a model needs to identify digits from 0 through 9.
There are ten possible classes.
The Model Chooses One Class
When a new input arrives, the model considers the possible classes and produces a prediction.
The important idea is that the output is one of the available categories.
Simple Python Example
Here is a small example using scikit-learn. The model predicts one of three possible classes.
from sklearn.linear_model import LogisticRegression
X = [
[1],
[2],
[3],
[6],
[7],
[8],
[11],
[12],
[13]
]
y = [
"Small",
"Small",
"Small",
"Medium",
"Medium",
"Medium",
"Large",
"Large",
"Large"
]
model = LogisticRegression()
model.fit(X, y)
prediction = model.predict([[7]])
print(prediction)
In this example there are three possible classes:
When the model receives the new value 7, it predicts one of those classes.
Multi-Class Classification means choosing one class from more than two possible classes.
The model learns patterns from labeled training data and then assigns new data to one of the available categories.