How do you extract human-readable if-then rules from a fitted decision tree?

Quick Overview

Asks how to turn a fitted decision tree into a list of human-readable if-then rules. Tests knowledge of how a tree is stored, how to traverse it in scikit-learn, and how to make the resulting rules short, correctly labeled and trustworthy.

How do you extract human-readable if-then rules from a fitted decision tree?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

How do you extract human-readable if-then rules from a fitted decision tree? ```hint Start from one leaf Look at what the fitted model stores for each node, and ask what all the training samples that reach a single leaf have in common. ``` ### What a Strong Answer Covers - How a path through the tree maps to one rule, and what the rule predicts. - At least one concrete way to produce the rules, either a library exporter or a traversal of the fitted tree's node arrays. - Steps that make the rules readable: merging repeated conditions on a feature, attaching support and confidence, and controlling the number of rules. - Pitfalls such as mapping a leaf to the wrong class label, rounding thresholds, and trusting training-set confidence. ### Follow-up Questions - How would you get rules out of a random forest or a gradient-boosted model, where there is no single tree? - How do you find which rule produced a particular prediction? - How would you present a split on a one-hot encoded feature to a non-technical reader? - How would you check that each rule's reported support and confidence hold on new data?

Overview: Asks how to turn a fitted decision tree into a list of human-readable if-then rules. Tests knowledge of how a tree is stored, how to traverse it in scikit-learn, and how to make the resulting rules short, correctly labeled and trustworthy.

Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

How do you extract human-readable if-then rules from a fitted decision tree?

What a Strong Answer Covers Guidance

  • How a path through the tree maps to one rule, and what the rule predicts.
  • At least one concrete way to produce the rules, either a library exporter or a traversal of the fitted tree's node arrays.
  • Steps that make the rules readable: merging repeated conditions on a feature, attaching support and confidence, and controlling the number of rules.
  • Pitfalls such as mapping a leaf to the wrong class label, rounding thresholds, and trusting training-set confidence.

Follow-up Questions Guidance

  • How would you get rules out of a random forest or a gradient-boosted model, where there is no single tree?
  • How do you find which rule produced a particular prediction?
  • How would you present a split on a one-hot encoded feature to a non-technical reader?
  • How would you check that each rule's reported support and confidence hold on new data?