Interpreting a Decision Tree
Explore how to interpret decision tree models in the context of loan approval predictions. Learn to translate the tree's splits into clear if-then rules, trace how individual applications follow specific decision paths, and understand the significance of feature importance. This lesson helps you explain model predictions to non-technical audiences while recognizing the limits of what these interpretations can claim, ensuring accurate and responsible explanations.
We'll cover the following...
A declined loan application needs an explanation that a non-technical audience can inspect. A single decision tree supports that explanation because its prediction follows a visible sequence of threshold questions. With a validated tree selected, we can translate those questions into statements such as: if debt_to_income <= 0.36 and delinquencies <= 1, predict approval.
A path is the sequence of splits one applicant follows from the root node to a leaf. A rule is the combined set of conditions along that path. A leaf prediction is the class or class probability stored at the final leaf. These objects describe what the fitted model did for its training pattern. They do not establish that a feature causes an approval or decline, and a readable tree is not automatically fair.
Reading the tree as rules
The tree first exposes its global structure as indented text, so we can turn each root-to-leaf route into a clear if-then rule. The synthetic loan data uses income, debt_to_income, delinquencies, and credit_history_years, which makes each split readable without decoding feature numbers.
Lines 6–40: The code generates a self-contained synthetic loan dataset with the lesson’s four feature names and an
approvedtarget, using a probability model that creates threshold-like structure a depth-3 tree can learn.Lines 48–83: The ...