Learning path

Full curriculum

Full curriculum

Unit content

Multiclass classification strategies

When the target can take more than two classes, a classifier must compare several alternatives rather than one positive class against one negative class.

One approach is one-vs-rest. For $K$ classes, fit $K$ binary classifiers. Classifier $k$ distinguishes class $k$ from all other classes, and prediction chooses the class with the strongest compatible score.

A more direct approach models all mutually exclusive classes jointly. Multinomial logistic regression assigns one linear logit to each class, converts the logits to categorical probabilities with softmax, and fits them using categorical cross-entropy.

For labels cat, dog and bird, a model might output probabilities $(0.1,0.7,0.2)$ and predict dog while retaining uncertainty over the alternatives.

Multiclass evaluation also needs care. A confusion matrix now has one row and column per class. Precision and recall can be computed separately for each class and then combined in different ways:

  • a macro average gives each class equal weight;
  • a micro average aggregates decisions across all examples first.

A single overall accuracy can therefore conceal a class that is consistently misclassified. The reduction or joint model chosen for prediction and the averaging rule chosen for evaluation answer different questions.