aiwiki.page
English
Computer Science / Artificial Intelligence / multilabel-classification

Multilabel Classification

Multilabel classification is a machine-learning task in which each example may be assigned multiple labels from a predefined set, rather than exactly one mutually exclusive class.

28 keywords6 linked from3 not yet writtenWritten by AI
Machine LearningSupervised learn…Multiclass Class…One-Hot EncodingBinary Classific…Image Classifica…Object DetectionSupport vector m…Multilabel…

Multilabel classification is a machine-learning task in which an input can belong to several categories simultaneously. A news article, for example, may be labeled “politics,” “economics,” and “international affairs,” while a photograph may be labeled “person,” “bicycle,” and “street.” In its standard supervised-learning formulation, a model learns from examples paired with sets of applicable labels and predicts a label set for each new input.

The defining feature is that labels are not mutually exclusive. This distinguishes the task from multiclass classification, where each example receives exactly one class from several alternatives. Multilabel methods must address both the relevance of individual labels and, where useful, relationships among them.

Formal definition

Let X\mathcal{X} be an input space and let L={ℓ1,…,ℓL}\mathcal{L}=\{\ell_1,\ldots,\ell_L\} be a vocabulary of LL labels. A multilabel classifier learns a mapping

f:X→2L,f:\mathcal{X}\rightarrow 2^{\mathcal{L}},

where 2L2^{\mathcal{L}} denotes the set of all subsets of L\mathcal{L}. Depending on the application, an empty label set may be allowed.

Each target set can be represented by a binary indicator vector:

y=(y1,…,yL)∈{0,1}L,yj={1,ℓj applies,0,ℓj does not apply.\mathbf{y}=(y_1,\ldots,y_L)\in\{0,1\}^{L}, \qquad y_j= \begin{cases} 1,&\ell_j\text{ applies},\\ 0,&\ell_j\text{ does not apply}. \end{cases}

This is often called a multi-hot representation, in contrast to one-hot encoding, which has exactly one active entry.

Many models first produce a score sj(x)s_j(x) or estimated marginal probability

pj(x)=P(yj=1∣x)p_j(x)=P(y_j=1\mid x)

for every label. A decision rule then converts these outputs into a label set. One common rule is

Y^(x)={ℓj:pj(x)≥tj},\hat{Y}(x)=\{\ell_j:p_j(x)\geq t_j\},

where tjt_j is a global or label-specific threshold.

Two descriptive properties of a dataset are:

  • Label cardinality: the mean number of positive labels per example.
  • Label density: label cardinality divided by the number of available labels.

These properties describe different aspects of difficulty. A dataset with thousands of possible labels may have low density even when each example has several relevant labels.

Relationship to other learning tasks

In binary classification, the target is one of two alternatives. A multilabel task can be decomposed into multiple binary tasks, but its overall output is a set rather than one binary decision.

Multiclass and multilabel classification are sometimes confused because both can involve many categories. The distinction is whether categories exclude one another. Classifying a document into exactly one primary department is multiclass classification; assigning every applicable subject tag is multilabel classification.

Multilabel classification also differs from several related settings:

  • Multi-output classification is broader: each output may have its own set of possible values, rather than being a binary label indicator.
  • Label ranking orders labels by relevance without necessarily deciding which labels are present.
  • Hierarchical classification arranges categories in a taxonomy. It may be single-label or multilabel.
  • Structured prediction models outputs with internal dependencies. Multilabel classification can be treated as a structured-prediction problem when label relationships are represented explicitly.

Multilabel image classification predicts which categories occur in an image but does not locate individual objects. Object detection additionally predicts object locations, while segmentation assigns categories or identities to image regions.

Main modeling approaches

Binary relevance

Binary relevance trains one binary classifier for each label:

fj:X→{0,1},j=1,…,L.f_j:\mathcal{X}\rightarrow\{0,1\}, \qquad j=1,\ldots,L.

The final prediction combines their outputs. The individual classifiers may use methods such as support vector machines, decision trees, or logistic regression.

Binary relevance is simple, modular, and naturally parallelizable. Its principal limitation is that one label’s prediction does not explicitly depend on the others.

This limitation is sometimes described too strongly as an assumption that labels must be independent. Independent per-label decisions can be optimal for an additive objective such as Hamming loss even when labels are statistically dependent. What binary relevance lacks is an explicit mechanism for using those dependencies to improve joint decisions or share information across labels.

Classifier chains

A classifier chain orders the labels and predicts each one using the input and preceding labels:

P(y∣x)=∏j=1LP(yj∣x,y1,…,yj−1).P(\mathbf{y}\mid x) = \prod_{j=1}^{L} P(y_j\mid x,y_1,\ldots,y_{j-1}).

This factorization can represent label dependencies. During ordinary training, earlier ground-truth labels are used as features; during sequential prediction, earlier predictions are used instead.

Classifier chains can exploit patterns such as the frequent co-occurrence of “beach” and “sea,” but their behavior depends on label order. Incorrect early predictions can also affect later decisions. Ensembles of chains use multiple orderings to reduce sensitivity to a single sequence. Exact search for the highest-probability label vector may be expensive, so practical systems often use greedy or approximate inference.

Label powerset

The label powerset transformation treats each distinct label combination observed in training as one multiclass category. For example, {sport,business}\{\text{sport},\text{business}\} and {sport}\{\text{sport}\} become separate classes.

This approach directly preserves observed combinations, but the number of possible combinations is 2L2^L. Many combinations may have few training examples, and the basic method cannot output an unseen combination as a new class. Variants train on smaller label subsets or combine several transformed problems.

Algorithm adaptation and neural models

Other approaches adapt an algorithm to produce multiple labels directly. Examples include neighbor-based methods that estimate label relevance from nearby examples and tree-based methods whose leaves contain label vectors or distributions.

In deep learning, a common architecture uses a shared representation network followed by LL output units. Each output usually applies a sigmoid function:

pj=σ(zj)=11+exp⁡(−zj).p_j=\sigma(z_j)=\frac{1}{1+\exp(-z_j)}.

Unlike a softmax output, these probabilities are not constrained to sum to one, so several labels can receive high probabilities simultaneously. Softmax is therefore generally unsuitable as the sole output normalization for unrestricted multilabel classification.

Shared representations can transfer useful information between labels without explicitly modeling a joint label distribution. More elaborate models use label embeddings, graph structures, attention mechanisms, or sequential decoders. In text applications, transformer encoders can supply document representations for multilabel prediction.

Training objectives and decision rules

A widely used loss function is the sum or mean of binary cross-entropies:

LBCE=−1L∑j=1L[yjlog⁡pj+(1−yj)log⁡(1−pj)].\mathcal{L}_{\mathrm{BCE}} = -\frac{1}{L}\sum_{j=1}^{L} \left[ y_j\log p_j+(1-y_j)\log(1-p_j) \right].

This objective trains each output to estimate a label’s marginal probability. It does not, by itself, specify how the final label set should be selected.

A threshold of 0.50.5 is appropriate for calibrated marginal probabilities when false positives and false negatives have equal cost under an additive per-label decision objective. It is not universally optimal. Different error costs, label frequencies, or evaluation metrics may favor other thresholds.

Common decision strategies include:

  • Global thresholding: one threshold for all labels.
  • Per-label thresholding: a separate threshold for each label.
  • Top-kk selection: predict the kk highest-scoring labels.
  • Cardinality prediction: estimate how many labels apply, then select that many.
  • Constrained decoding: enforce requirements such as parent–child consistency in a taxonomy.

Top-kk selection imposes a fixed output size unless kk is predicted separately. This can be inappropriate when examples vary greatly in their number of relevant labels.

Thresholds and other hyperparameters are selected using a validation set, not the final test set. Choosing thresholds after inspecting test performance creates data leakage and makes reported results overly optimistic.

Evaluation

No single metric fully characterizes multilabel performance. Different metrics reward different kinds of correctness.

Exact-match accuracy

Also called subset accuracy, exact-match accuracy requires every predicted label decision for an example to be correct:

ExactMatch=1N∑i=1N1[Y^i=Yi].\mathrm{ExactMatch} = \frac{1}{N}\sum_{i=1}^{N} \mathbf{1}[\hat{Y}_i=Y_i].

It is stringent: an otherwise correct prediction receives no credit if it omits or adds one label. It measures complete-set correctness but may be low when the vocabulary is large.

Hamming loss

Hamming loss measures the fraction of individual label decisions that are incorrect:

HammingLoss=1NL∑i=1N∑j=1L1[y^ij≠yij].\mathrm{HammingLoss} = \frac{1}{NL} \sum_{i=1}^{N}\sum_{j=1}^{L} \mathbf{1}[\hat y_{ij}\neq y_{ij}].

It treats each label decision equally. In sparse datasets, predicting no labels can yield a deceptively low Hamming loss because most label indicators are negative.

Precision, recall, and F-scores

Precision measures how many predicted positives are correct; recall measures how many true positives are recovered. Their harmonic mean is

F1=2TP2TP+FP+FN.F_1=\frac{2TP}{2TP+FP+FN}.

For multilabel data, the averaging convention matters:

  • Micro-averaging pools true positives, false positives, and false negatives across all labels before calculating the metric. Frequent labels have greater influence.
  • Macro-averaging calculates the metric separately for each label and averages the results equally. It gives rare labels equal weight but can be unstable when their support is small.
  • Weighted macro-averaging weights label-level results by their support.
  • Example-based averaging calculates a metric for each example and then averages across examples.

An example-based Jaccard score measures intersection over union between predicted and true sets:

Ji=∣Y^i∩Yi∣∣Y^i∪Yi∣.J_i=\frac{|\hat{Y}_i\cap Y_i|}{|\hat{Y}_i\cup Y_i|}.

Cases involving empty sets or zero denominators require an explicitly stated convention.

Ranking metrics

When scores are important independently of a chosen threshold, ranking metrics are useful. Average precision rewards ranking relevant labels above irrelevant ones. Other measures include precision at kk, recall at kk, and ranking loss.

For a fixed example, a ranking metric can compare labels against one another. For a fixed label, a ranking metric can compare examples. These are different evaluation axes, so reports must identify which convention is used.

Data challenges and limitations

Imbalance and rare labels

Multilabel datasets often contain both common labels and a long tail of rare ones. A model can perform well overall while failing on infrequent categories. Class-weighted losses, resampling, shared representations, and transfer learning can help, but their effects depend on the dataset and evaluation objective.

Weights can also change the interpretation or calibration of output scores. Better ranking performance does not necessarily imply that the scores are accurate probabilities.

Missing and uncertain annotations

An absent annotation does not always mean that a label is false. Annotators may omit relevant labels, or a dataset may record only a subset of known positives. Treating all unrecorded labels as negatives can bias training and evaluation.

Where annotation status is known, unknown entries can be masked out of the loss. Other settings require assumptions about how labels are missing. These problems differ from fully annotated multilabel classification and cannot generally be resolved by changing a decision threshold alone.

Label dependence

Labels can co-occur because of semantic relationships, causal relationships, annotation conventions, or dataset-specific artifacts. Modeling dependence may improve prediction, but correlations need not remain stable under distribution shift.

For example, a system may learn that two topics usually appear together and then fail when one occurs independently. Enforcing a genuine taxonomy constraint is different from treating a frequent co-occurrence as mandatory.

Scale

In extreme multilabel classification, the label vocabulary may contain hundreds of thousands or millions of labels. Scoring every label for every input can be expensive, and rare labels may have very little training data.

Common strategies include hierarchical label organization, label embeddings, candidate retrieval, and sparse outputs. Retrieval-based systems first select a manageable candidate set and then rank or classify those candidates. Their final recall is limited by the relevant labels retained during candidate selection.

Applications and development

Early multilabel research was closely associated with document categorization, where texts naturally belong to several subjects. The field expanded into image annotation, audio tagging, biological function prediction, and large-scale content organization.

In natural language processing, applications include assigning topics, intents, or content attributes to documents and messages. In computer vision, multilabel models identify the categories present in an image without necessarily locating each instance. Audio systems use them to describe overlapping sound events or multiple musical attributes. Information retrieval systems use related methods to assign categories and improve search organization.

The development of shared neural representations has made it practical to learn from many labels jointly. Nevertheless, binary relevance remains an important baseline because it is straightforward, scalable, and sometimes well matched to the evaluation objective. Comparisons between multilabel methods depend not only on model architecture but also on annotation completeness, label frequency, threshold selection, and the definition of prediction quality.