How do you keep hierarchical predictions consistent so that a predicted child label always implies its parent label?

Quick Overview

Explain how to make hierarchical or multi-label classifiers output label sets where every predicted child comes with its parent. Tests top-down decoding, post-hoc score repair on trees and DAGs, threshold choice, constraint-aware models and label propagation during training.

How do you keep hierarchical predictions consistent so that a predicted child label always implies its parent label?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

In hierarchical classification the labels form a tree or a DAG, for example a taxonomy where Dog sits under Mammal, which sits under Animal. A prediction that contains Dog but not Mammal is invalid. How do you keep hierarchical predictions consistent so that a predicted child label always implies its parent label? ```hint Where to enforce it The rule can be enforced while decoding, by editing the scores after the model runs, or inside the model itself. Consider what each option costs. ``` ```hint Scores and thresholds Suppose every child's score is at most its parent's score. What must be true of the thresholds for the final label set to be valid? ``` ### What a Strong Answer Covers - A precise statement of the constraint: a node is predicted only if all its ancestors are, which in score terms means a child never outscores its parent - Consistency by construction through top-down decoding or leaf prediction plus ancestors, and the error propagation that comes with top-down decoding - Post-hoc score repair (bottom-up max or top-down min), the processing order in a deep tree or DAG, and how the thresholds must be set - Models that build in the constraint, such as conditional probabilities multiplied along the path or a max-constraint output layer - Propagating labels to ancestors in the training data and training conditional classifiers on the right subset of examples ### Follow-up Questions - When would you choose bottom-up max over top-down min, and how does each one shift precision and recall at different depths? - How do you handle a label DAG where a node has several parents? - Top-down inference cannot recover from a wrong decision near the root. How would you reduce that error propagation? - Which metrics would you use to evaluate hierarchical predictions, and why is flat per-label F1 not enough?

Overview: Explain how to make hierarchical or multi-label classifiers output label sets where every predicted child comes with its parent. Tests top-down decoding, post-hoc score repair on trees and DAGs, threshold choice, constraint-aware models and label propagation during training.

Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

In hierarchical classification the labels form a tree or a DAG, for example a taxonomy where Dog sits under Mammal, which sits under Animal. A prediction that contains Dog but not Mammal is invalid. How do you keep hierarchical predictions consistent so that a predicted child label always implies its parent label?

What a Strong Answer Covers Guidance

  • A precise statement of the constraint: a node is predicted only if all its ancestors are, which in score terms means a child never outscores its parent
  • Consistency by construction through top-down decoding or leaf prediction plus ancestors, and the error propagation that comes with top-down decoding
  • Post-hoc score repair (bottom-up max or top-down min), the processing order in a deep tree or DAG, and how the thresholds must be set
  • Models that build in the constraint, such as conditional probabilities multiplied along the path or a max-constraint output layer
  • Propagating labels to ancestors in the training data and training conditional classifiers on the right subset of examples

Follow-up Questions Guidance

  • When would you choose bottom-up max over top-down min, and how does each one shift precision and recall at different depths?
  • How do you handle a label DAG where a node has several parents?
  • Top-down inference cannot recover from a wrong decision near the root. How would you reduce that error propagation?
  • Which metrics would you use to evaluate hierarchical predictions, and why is flat per-label F1 not enough?