Multilabel Classification
In multilabel classification, each instance (data sample) can belong to multiple classes simultaneously. Unlike multiclass classification (where one instance has exactly one label), multilabel tasks allow several labels to be true at once.
Movie: Avengers, Labels (Genres): [Action, Sci-Fi, Adventure]
Movie: Titanic, Labels (Genres): [Romance, Drama]
Mathematical Formulation
Let’s understand Math behind it.
X = {x1,x2,…,xn} : feature vectors of n samples
Y = {y1,y2,…,yL} : set of all possible labels (total L labels)
Each instance xi has a label vector:
yi = [yi1, yi2, …, yiL] ∈ {0,1}
where yij = 1 if label j applies to instance i, otherwise 0.
Labels: [Action, Sci-Fi, Adventure, Animation, Family, Romance, Drama, Thrill]
Representing Samples as Vectors
A vector = numeric representation of a sample’s features.
Let’s say:
x1 = duration
2x2 = budget
x3 = has famous actor (1 or 0)
Then: x = [x1, x2, x3] is a feature vector for one movie.
So, for Avengers:
x_Avengers = [180,220,1]
And Titanic:
x_Titanic = [195,200,1]
So, if you have 4 movies, you’ll have 4 samples, each with a feature vector.
let's understand how we get y?
Here:
- Features (X): duration, budget, has famous actor
→ numeric vector x = [180,220,1] - Label (Y): genres
→ numeric vector y = [1,1,1,0, 0,0,0,0] (for 8 possible genres)
Labels: [Action, Sci-Fi, Adventure, Animation, Family, Romance, Drama, Thrill]
So, both X and Y are vectors, but Y is the prediction of X, here model predicted these [Action, Sci-Fi, Adventure] genre for the movie Avengers, and its numeric vector y becomes this (y = [1,1,1,0, 0,0,0,0]).
Let's dive into the complete processes of calculating Y:
We model the relationship as a function:
fθ:X→Y
That means:
y=fθ(x)
So, the label is the output of a function whose input is the feature vector.
In machine learning, we learn fθ (the mapping) from data — i.e., how feature patterns map to labels.
Modeling the Problem
Usually, we model multilabel classification as L independent binary classification problems — one per label.
That means:
where:
- wj, bj are parameters for label j,
- σ(z) = 1 / (1+e^−z) is the sigmoid function.
Each output neuron gives a probability between 0 and 1 for one label.
So the final output is:
Loss Function (Binary Cross-Entropy)
Since each label is independent, we use binary cross-entropy loss summed across labels:
multilabel classification uses:
- Sigmoid activation → gives a probability for each label
- Binary yes/no decision for each label
So, the correct loss is:
Then the total loss across all samples is:
To know BCE’s mathematical derivative visit and search BCE: Machine Learning Metadata. Know terms Machine Learning uses… | by Mausam | Nov, 2025 | Medium
Summary
Each label is treated as an independent binary classification problem.
Get Mausam’s stories in your inbox
Join Medium for free to get updates from this writer.
If you have 5 labels, you train 5 binary classifiers in parallel.
Input and Output Representation
Input (Features)
Each sample is converted into a feature vector:
e.g., text → embeddings, image → pixel vector, etc.
Output (Labels)
Labels are stored in a multi-hot vector:
Example with 4 genres:
- Action
- Comedy
- Drama
- Horror
Movie labeled Action + Drama →
y = [1, 0, 1, 0]
Model Architecture
Output Layer Activation: Sigmoid per label
Loss Function
Use Binary Cross Entropy (BCE) for each label independently:
Weight Update
Training uses gradient descent with optimizers like:
- Adam ← most popular
- SGD
- RMSProp
These compute gradients and update the weights to reduce loss.
Prediction
Sigmoid outputs probabilities, e.g.:
[0.82, 0.41, 0.96, 0.23]
To convert to 0/1 labels, use a decision threshold (usually 0.5):
- ≥ 0.5 → label = 1
- < 0.5 → label = 0
Predicted labels:
[1, 0, 1, 0]
Evaluation Metrics
Accuracy is misleading for multilabel classification.
Better metrics:
Precision
Recall
F1 Score (most important)
Macro F1
Micro F1
These measure how well the model predicts positive labels, which are often imbalanced.
Why Multilabel Classification is Hard
- Labels are often imbalanced
- Labels can be correlated (Action + Adventure)
- Multiple decisions must be made per sample
Real-World Examples
Movie genre prediction
Tag suggestion (Instagram hashtags)
Medical diagnosis (multiple diseases)
Music emotion tagging
Toxic comment classification (multiple types of toxicity)
Multilabel classification predicts multiple independent binary labels for each sample using sigmoid outputs, binary cross entropy loss, and F1-based evaluation metrics.









