liveBook · Manning

Multiclass classification

As explained in Deep Learning with R, Third Edition

A multiclass classification model is a predictive model that assigns inputs to one of more than two classes and produces scores or probabilities for those classes.

Multiclass classification chooses among more than two classes. In single-label multiclass classification, each input belongs to exactly one class. A Reuters newswire classifier, for example, assigns each article to one of 46 mutually exclusive topics. section 4.2

Set up a 46-topic classifier

For a single-label classifier, use a final Dense layer with 46 units and softmax activation. Match the loss to the targets: categorical_crossentropy for one-hot targets, or sparse_categorical_crossentropy for integer-encoded targets. The number of output units follows the number of topics. section 4.2 section 20.6

Check the labeling task before choosing that setup. If an input can have several labels, it is a multilabel problem instead: use a sigmoid output with binary_crossentropy and K-hot targets, rather than softmax’s single-class constraint. section 4.2 section 20.6

Problem framing comes first: identify the inputs, the available annotations, and whether the desired output is one class or several. Define success metrics and validation splits before settling on an architecture. section 6.1.1 section 20.6

How Deep Learning with R, Third Edition covers it

How deep it goes
Gives a worked task and practical output-layer and loss choices, without deriving the mathematics of softmax or cross-entropy.
Examples
Uses Reuters newswires assigned to 46 mutually exclusive topics.
What it assumes
Assumes prior exposure to vector inputs and binary neural-network classification; introduces the many-class task through newswires.
What you can do after
Build it from scratch by matching a single-label classifier’s softmax units and cross-entropy loss to its classes and target encoding.
How it connects
Contrasts binary classification and multilabel classification, and ties model design to target encoding and validation.

Also explained in

Compare how 2 books explain multiclass classification →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.