Stacked-MLkNN: A stacking based improvement to Multi-Label k-Nearest Neighbours

Arjun Pakrashi, Brian Mac Namee

Abstract

Multi-label classification (MLC) involves predicting multiple non-exclusive labels for a single instance. While the Multi-Label k-Nearest Neighbors (MLkNN) algorithm is widely used due to its simplicity and lazy learning nature, it often fails to account for label dependencies. This paper introduces Stacked-MLkNN, a two-layer stacking approach where the first layer generates label probabilities that serve as features for a second kNN layer. This architecture allows the model to learn label co-occurrence patterns without sacrificing the benefits of lazy learning. Evaluation on 12 benchmark datasets shows that Stacked-MLkNN significantly improves performance over baseline methods, achieving a superior average rank of 2.12.

Introduction

In multi-label classification, a single data point can belong to multiple categories simultaneously—for example, a news article tagged with both "Politics" and "Economics." A common approach is Binary Relevance, which trains independent classifiers for every label. However, this method ignores the fact that labels are rarely independent. If an image is labeled "Ocean," it is highly likely to also be labeled "Water" and unlikely to be labeled "Desert."

Standard algorithms like MLkNN (a probabilistic version of k-Nearest Neighbors) treat labels independently, missing out on these valuable associations. Furthermore, many multi-label datasets suffer from extreme "label imbalance," where some tags are ubiquitous while others are incredibly rare. Stacked-MLkNN addresses these issues by explicitly modeling label relationships through a stacked architecture.

Methodology

The proposed Stacked-MLkNN is a two-layer approach based on the concept of "stacking," where the output of one model serves as the input for another. The process consists of two main phases:

  1. Layer 1: A standard MLkNN model takes the original input features ($X$) and calculates the probability of each label being relevant ($p(\hat{Y})^{(1)}$).
  2. Layer 2: Instead of using the original features, this second MLkNN layer uses the predicted probabilities from Layer 1 as its input. It then produces the final prediction ($p(\hat{y}_t)^{(2)}$).
The Stacked-MLkNN architecture: (a) generation of the second-layer dataset and (b) the two-step prediction process.

By processing the probabilities of all labels together in the second layer, the algorithm can identify patterns. If Layer 1 is uncertain about a rare label but highly confident about a related common label, Layer 2 can leverage that association to refine the prediction. Crucially, because both layers utilize kNN, the method remains a "lazy learner," requiring no heavy upfront training phase and allowing for easy updates as new data arrives.

Experimental Evaluation

The researchers evaluated Stacked-MLkNN on 12 well-known multi-label datasets spanning various domains, including biology (yeast, genbase), multimedia (scene, emotions), and text (enron, bibtex). These datasets vary significantly in "Cardinality" (average labels per point) and "MeanIR" (label imbalance), providing a robust stress test for the algorithm.

Performance was measured primarily using the Macro-averaged F-score (MAF). The authors argue that the common "Hamming Loss" metric can be misleading for imbalanced data, as a model can achieve a high score simply by predicting "zero" for all rare labels. MAF forces the model to perform well across both common and rare categories.

Results and Discussion

Stacked-MLkNN consistently outperformed the baseline MLkNN and several other state-of-the-art instance-based learners. Across the 12 datasets, Stacked-MLkNN achieved an average rank of 2.12, significantly better than the standard MLkNN (4.08) and the nearest competitor, IBLR-ML+ (3.00).

Performance comparison and average ranks across 12 datasets. Stacked-MLkNN achieves the best average rank of 2.12.

Statistical analysis using the Friedman aligned rank test confirmed that these improvements were significant (p < 0.05). The model achieved the #1 or #2 rank on 9 out of the 12 datasets, demonstrating high adaptability across different data types. The core insight is that moving the problem into "label space" (using probabilities as features) allows the model to focus effectively on label co-occurrence.

Conclusion

Stacked-MLkNN provides a powerful yet simple improvement to the standard MLkNN algorithm by capturing label dependencies through stacking. While it is computationally more expensive at query time due to the dual kNN passes, its status as a strictly lazy learner makes it highly flexible for dynamic datasets. Future work may explore integrating original input features into the second layer or combining the architecture with specialized preprocessing techniques to further mitigate label imbalance.

Summary updated

BibTeX
@inproceedings{pakrashi2017stacked,
  author = {Arjun Pakrashi and Brian Mac Namee},
  title = {{Stacked-MLkNN: A stacking based improvement to Multi-Label k-Nearest Neighbours}},
  booktitle = {LIDTA@PKDD/ECML},
  year = {2017},
}
Figure