Multiclass Formulation
Explore the multiclass extension through softmax activation.
We'll cover the following
Multiclass extension
The logistic regression model offers two significant advantages: the ability to learn probabilities and the natural extension to handle multiple classes. Let’s explore how we can extend a binary classification model to a multiclassification model with classes. This technique is also called one-vs-all (one-vs-rest).
Algorithm
For each class in the dataset:
-
Set the labels of class to 1, indicating positive instances.
-
Set the labels of all other classes to 0, representing negative instances.
-
Apply logistic regression on the modified dataset, treating it as a binary classification problem with class as the positive class (1) and all other classes as the negative class (0). Save the corresponding model parameters .
-
Predict the probability , where is the input vector of the test instance.
-
Rescale all class predictions by dividing each by the sum of all predictions across all classes . This step ensures that the probabilities sum up to 1, providing normalized probabilities.
-
Finally, select the class with the maximum rescaled prediction as the predicted class for the test instance .
Get hands-on with 1400+ tech skills courses.