Decision trees

In a decision tree, conditions are depicted as nodes, values are represented by branch lines, and actions are displayed in boxes at the ends of branches.

Decision trees provide an alternative and more convenient way of viewing and managing large sets of business rules, especially when these rules are not symmetric.

Large sets of nonsymmetrical rules may be easier to understand using decision trees, where the path from the first condition to the end of the actions along any branch corresponds to one rule.

Decision tree showing the path from the first condition to the end of the actions

Looking at the following figure, you can see that decision trees are easy to use once you understand that:

For example, this simple decision tree:

Simple decision tree showing a condition, a branch, and an action

corresponds to the following rule:

if
   the grade in the loan report is ‘A’
then
   in the loan report, accept the loan with the message “Loan accepted”

Adding branches means adding new rules that have a different value for the condition.

For example, the following decision tree has three rules, one for the case where the loan report is ‘A’, another for ‘B’, and a third one for ‘C’:

Decision tree which has three rules

You can put as many actions as you want at the end of each branch. You can also add another condition to a branch.

For example, rules 1 and 2 in the following decision tree have only one condition (Grade), while rules 3 and 4 have a second condition to consider (Spouse bankruptcy) before performing the actions:

Decision tree showing two rules with one condition, and two rules with two conditions

Finally, you can put an ‘Otherwise’ branch for values of the condition not covered in any of the other branches:

Decision tree showing an Otherwise branch

You can lay out your decision tree vertically or horizontally for optimal viewing, as well as set or remove consistency checking.

Preconditions

A decision tree contains a preconditions section that lets you:

If the precondition is not satisfied, none of the rules in the decision tree can be evaluated.

For example, you could apply the following precondition to a decision tree:

definitions
   set ‘wealthy customer’ to a customer
      where the average monthly balance of this customer 
                                      is more than $1 000 000
if
   the state of residence of ‘wealthy customer’ is NY

Applying this precondition to a decision tree limits the scope of the decision tree rules to only those customers with an average monthly balance of $1 000 000 and living in New York. It also allows you to use the variable wealthy customer in the tree.

Preconditions are tested before each rule in a tree is executed.