Multilabel Classification with R Package mlr

Philipp Probst, Quay Au, Giuseppe Casalicchio, Clemens Stachl, Bernd Bischl

Abstract

We implemented several multilabel classification algorithms in the machine learning package mlr. The implemented methods include binary relevance, classifier chains, nested stacking, dependent binary relevance, and stacking. These can be used with any base learner accessible in mlr. Additionally, the package provides access to multilabel versions of randomForestSRC and rFerns. These methods can be easily compared using various performance measures and resampling methods within the standardized mlr framework.

Introduction

In standard classification, an observation belongs to exactly one category. In multilabel classification, an instance can belong to several categories simultaneously. For example, a song might be tagged as both "Rock" and "Ballad," or an image might contain both "Sunset" and "Mountains."

The primary challenge in this field is label dependency: labels are rarely independent. A photo containing a "Sunset" is statistically more likely to include "Clouds" and less likely to include "Snow." While specialized software like MEKA or Mulan existed, the R ecosystem lacked a unified interface for swapping base algorithms, handling complex resampling, and accounting for label correlations within a single pipeline. The mlr package now fills this gap.

Methodology

The mlr framework integrates two main approaches to multilabel tasks:

1. Algorithm Adaptation

This involves using algorithms specifically designed for multilabel data, such as randomForestSRC and rFerns. These models inherently handle multiple outputs.

2. Problem Transformation

These methods decompose the multilabel problem into several single-label problems. The package highlights four key strategies:

  • Binary Relevance (BR): The baseline approach. It trains one independent model per label. While fast, it ignores label correlations.
  • Classifier Chains (CC): Models are trained in a sequence. Each model incorporates the true labels of preceding models in the chain as additional features.
  • Dependent Binary Relevance (DBR): Each label's model is trained using the true values of all other labels as features.
  • Nested Stacking (NST) & Stacking (STA): These address the "training-test mismatch." Since true labels are unavailable at prediction time, these methods use internal cross-validation during training to generate predicted labels. This ensures the model learns to handle the noise it will actually encounter in real-world applications.
A typical multilabel dataset structure where each instance has multiple binary labels.

Key Insights: Modeling Dependencies

A critical realization in multilabel research is that training on perfect ground-truth labels (as in standard CC) can lead to failure during testing when the model must rely on its own imperfect predictions. Methods like Nested Stacking solve this by intentionally training on "noisy" predictions generated via cross-validation.

The paper categorizes these methods along two axes:

  1. Conditioning: Partial (looking at some previous labels) vs. Full (looking at all other labels).
  2. Label Source: True labels vs. Predicted labels (simulated via stacking).
Illustration of training a classifier to predict a label using both original features and other labels as additional features.

Experimental Results

The authors conducted a benchmark using 10 diverse datasets across audio, text, biology, and image classification. Key findings include:

  • Metric Sensitivity: Performance varies by metric. Classifier Chains (CC) often performed best for Subset 0/1 loss, where the entire set of labels must be correct. DBR and Stacking generally excelled in F1-index and Accuracy by leveraging the full context of all labels.
  • Base Learner Impact: Using Adaboost as the base learner frequently outperformed Random Forest across various transformation methods.
  • Algorithm Adaptation vs. Transformation: Specialized algorithms like rFerns struggled with high-dimensional features, whereas transformation methods using robust base learners like rpart were more consistent.

Conclusion

By standardizing multilabel classification within mlr, the authors have enabled advanced features like parallelization and automated hyperparameter tuning. While computationally intensive methods like Stacking require more resources, they offer significant performance gains by effectively modeling label dependencies. Future work involves optimizing chain ordering for CC and further enhancing parallel execution for nested methods.

Summary updated

BibTeX
@article{probst2017multilabel,
  author = {Philipp Probst and Quay Au and Giuseppe Casalicchio and Clemens Stachl and Bernd Bischl},
  title = {{Multilabel Classification with R Package mlr}},
  journal = {R J.},
  year = {2017},
  doi = {10.32614/rj-2017-012},
}
Figure