liveBook · Manning

Decision rule

As explained in Ensemble Methods for Machine Learning

A human-readable if-then rule corresponding to a path from the root of a decision tree to a leaf.

A decision rule is a human-readable if-then condition describing one path from a decision tree’s root to a leaf. Each rule sends examples into one subpopulation, making the tree’s classification easier to inspect. section 9.1.2

Read a decision tree as a complete set of rules:

  • Follow each split from the root until reaching a leaf. section 9.1.2
  • Combine the conditions encountered along that path with and. section 9.1.2
  • Treat the leaf’s class as the rule’s result; the complete rule set covers every example without overlap. section 9.1.2

Iris classification

A compact tree can become three Python-style rules: petal width at most 0.8 predicts Iris-Setosa; otherwise, petal length at most 4.85 predicts Iris-Versicolour; larger values predict Iris-Virginica. section 9.1.2

Listing 9.1 Training and interpreting decision trees
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
iris = load_iris()                                                  #1
Xtrn, Xtst, ytrn, ytst = train_test_split(iris.data, iris.target,
                                          test_size=0.15)
 
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
model = DecisionTreeClassifier(                                     #2
           min_samples_leaf=40, criterion='entropy')
model.fit(Xtrn, ytrn)                                               #3
ypred = model.predict(Xtst)
print('Accuracy = {0:4.3}%'.format(accuracy_score(ytst, ypred) * 100))
 
 
import graphviz, re, pydotplus
dot = tree.export_graphviz(model, feature_names=iris.feature_names, 
                           class_names=['Iris-Setosa', 
                                        'Iris-Versicolour', 
                                        'Iris-Virginica'],
                           filled=True, impurity=False)
graphviz.Source(dot, format="png")                                  #4

Train a scikit-learn decision tree, inspect its accuracy, and export its structure for interpretation. section 9.1.2

How Ensemble Methods for Machine Learning covers it

How deep it goes
Explains root-to-leaf construction and coverage, while deferring detailed rule interpretation for deep trees.
Examples
Uses an Iris classifier with petal-width and petal-length thresholds expressed as Python-style if-then rules.
What you can do after
Evaluate decision-tree behavior by translating root-to-leaf paths into explicit classification conditions.
How it connects
Links decision rules to decision trees, leaf nodes, feature space, and model interpretability.

Also explained in

Compare how 2 books explain decision rule →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.