To Each Metric Its Decoding: Post-Hoc Optimal Decision Rules of Probabilistic Hierarchical Classifiers

Roman Plaud, Alexandre Perez-Lebel, Matthieu Labeau, Antoine Saillenfest, Thomas Bonald

Introduction

Hierarchical classification is a fundamental task in machine learning where classes are organized into a structured taxonomy, such as a tree. In such systems, a "Golden Retriever" is not just a label but also a "Dog," a "Canine," and a "Mammal." Despite this inherent structure, most modern classifiers are designed as "flat" models, outputting a probability distribution over the most specific leaf nodes. To produce a final prediction, practitioners typically rely on simple heuristics like the argmax rule—selecting the single most likely leaf.

However, this approach often fails to align with the actual metrics used to evaluate performance. This paper addresses this gap by introducing a framework for post-hoc optimal decoding, providing efficient algorithms to derive predictions that maximize expected utility for a variety of hierarchical metrics. The authors demonstrate that these optimal rules significantly boost performance, especially in "underdetermined" scenarios where model uncertainty is high.

The Limitations of Standard Heuristics

The standard argmax approach suffers from two primary issues:

  1. Ignoring Mistake Severity: In a hierarchy, not all errors are equal. Misclassifying a "Golden Retriever" as a "Labrador" is a minor taxonomic error, whereas misclassifying it as a "Cello" is a significant failure. Standard heuristics often treat these errors identically.
  2. Metric Misalignment: Different applications prioritize different outcomes. Some tasks require high precision (ensuring that when a label is predicted, it is correct), while others prioritize recall (identifying the correct leaf node even at the risk of lower precision).

When a model is uncertain, it might be safer to predict a broader parent category (e.g., "Dog") rather than guessing a specific leaf and risking a severe error. The challenge lies in the search space: for complex metrics like the hierarchical F-score ($hF_\beta$), the number of possible prediction subsets is exponentially large ($2^{|N|}$), making brute-force optimization impossible.

A Decision-Theoretic Framework for Decoding

The authors propose a post-hoc decoding framework that treats prediction as a decision-theoretic task. Instead of modifying the training process, they optimize how the model's output probabilities are interpreted at inference time. The goal is to find a prediction $h$ that minimizes the expected risk (or maximizes expected utility) given the model's output distribution:

$$\hat{h} = \arg\min_{h \in \mathcal{H}} \mathbb{E}_{y \sim P(y|x)} [L(h, y)]$$

Key Algorithmic Contributions

  • Hierarchically Reasonable Metrics: The authors define a class of "reasonable" metrics where predicting a parent node is always preferred over predicting a distant "cousin" node. They provide an efficient algorithm to solve this with a complexity of $O(d_{max} \cdot |L| + |N|)$, where $d_{max}$ is the tree depth and $L$ and $N$ represent leaf and total nodes, respectively.
  • Optimal $hF_\beta$ Decoding: The $hF_\beta$ score allows for predicting subsets of nodes. The authors derive a polynomial-time algorithm with $O(d_{max}^2 \cdot |N|)$ complexity to find the absolute optimal subset, turning a previously intractable problem into a feasible one.
  • Universal Applicability: Because these methods are post-hoc, they can be applied to any pre-trained probabilistic classifier without the need for retraining or architecture changes.

Experimental Evaluation

The framework was evaluated using several large-scale computer vision benchmarks:

  • TieredImageNet-H: A subset of ImageNet-1k reorganized into a tree structure containing 843 nodes and 608 leaves.
  • iNat19 (iNaturalist 19): A dataset featuring a natural 8-level biological hierarchy with 1190 nodes and 1010 leaves.
  • Model Architectures: The researchers tested 10 different architectures, ranging from classic CNNs (VGG11, ResNet-18) to modern Vision Transformers (Swin Transformers).

Insights: Uncertainty and the Precision-Recall Trade-off

A key finding of the study is that the choice of decoding strategy is most critical when the model is uncertain. In scenarios where the model is highly confident (e.g., 99% probability on a single leaf), most heuristics converge on the same answer. However, as uncertainty increases—demonstrated through a "blurring experiment" where input images were progressively obscured—the performance gap between optimal decoding and standard heuristics widened significantly.

The research also highlights a fundamental trade-off between different decoding styles:

  • Node-based heuristics (e.g., Majority Rule) tend to be conservative, favoring precision by retreating to internal nodes (like "Animal") when unsure.
  • Leaf-based heuristics (e.g., argmax) are aggressive, favoring recall by always selecting a specific species even if the probability is low.

Results and Impact

The optimal decoding strategies consistently outperformed common heuristics across every metric and model architecture tested. While performance gains were modest (1-5%) for some metrics, they reached up to 10% for Mistake Severity metrics. Furthermore, the proposed algorithms are approximately 60x faster than standard brute-force approaches for node predictions, making subset-level predictions computationally viable for real-time applications.

Limitations and Future Work

While powerful, the framework relies on the assumption that the model's output probabilities are well-calibrated. If a model is overconfident in an incorrect prediction, the optimal decoding rule will still be led astray. Future research may focus on integrating hierarchical recalibration techniques. Additionally, the current framework is limited to tree structures; extending these algorithms to Directed Acyclic Graphs (DAGs), which are common in complex taxonomies, remains an open challenge. Finally, while this study focused on image data, the application of these rules to hierarchical text classification (e.g., medical or legal tagging) is a promising next step.

Summary updated

BibTeX
@inproceedings{plaud2025each,
  author = {Roman Plaud and Alexandre Perez-Lebel and Matthieu Labeau and Antoine Saillenfest and Thomas Bonald},
  title = {{To Each Metric Its Decoding: Post-Hoc Optimal Decision Rules of Probabilistic Hierarchical Classifiers}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=5zsBvPOIUQ},
}
Figure