MSc Business Information Systems
Rule-Based Systems I: Decision Tables, Decision Trees, Visual Rule Modelling
Knut Hinkelmann
Prof. Dr. Knut Hinkelmann 2MSc BIS/
Rule-based Systems
Rule-based Systems consist of Rule base Fact base Inference engine
Rules are of the form IF <antecedent> THEN <consequent>
KnowledgeBase
InferenceComponent
Facts
Rules
Prof. Dr. Knut Hinkelmann 3MSc BIS/
Different Types of Rule-based Systems
Condition-Action Rules (Production Rules) <consequent> is a set of actions <antecedent> is a set of conditions Example:
IF car X has been sold THEN delete X from the catalogue
Logical rules <antecedent> and <consequent> are formulas of first-order
logic IF … THEN is equivalent to implication Example:
IF X is a man THEN X is mortal
Prof. Dr. Knut Hinkelmann 4MSc BIS/
Representation of Rules
There is a large variety of rule representations:
decision tables
decision trees
graphical representation
textual representation logical formulas Structured English „Code“
Prof. Dr. Knut Hinkelmann 5MSc BIS/
Decision Tables
A decision table is a compact form to represent a whole set of rules
A decision table can represent condition-action rules and also logical rules Condition-Action rules:
Logical Rules: The effectsrepresent possible decisionvalues
The second column represents a set of rules: one column for eachcombination of possible values for condition
Action entriesActions
Condition alternativesConditions
Effect entriesEffects
Condition alternativesConditions
Prof. Dr. Knut Hinkelmann 6MSc BIS/
Decision Table for Printer Diagnosiseach columnrepresents one rule
This decision table represents condition-action-rules
Prof. Dr. Knut Hinkelmann 7MSc BIS/
Decision Table for Health Insurance
Effects
N N N N N N Y Y Y Y Y Y 1. Deductible met? L L H H D D L L H H D D 2. Type of visitN Y N Y N Y N Y N Y N Y 3. Participating Physician?
X1. Reimburse 50%X 2. Reimburse 70%
X3. Reimburse 80%
X X X X 6. Impossible or N/A XXX X 5. No reimbursement
X 4. Reimburse 90%
12 11 10 9 8 7 6 5 4 3 2 1 Conditions
http://web.sxu.edu/rogers/sys/decision_tables.html
Reimbursement depends on whether decuctible is already met, whether the patient visited thedoctor‘s office (D), a hospital (H) or a lab (L) and whether the Doctor is a Participating Physician
Prof. Dr. Knut Hinkelmann 8MSc BIS/
Decision Tables – Reducing Combinations If effects for a several combinations are the same, the
combinations can be combined, reducing the numer of rules
Example: If Cause 1 is „Y“ and Cause 2 is „N“, the the effect does not
depend on the values of Cause 3 In this case, the value of Cause 3 does not need to be taken
into account
Causes Values 1 2 3 4 5 6 7Cause 1 Y, N Y Y Y N N N NCause 2 Y, N Y Y N Y Y N NCause 3 Y, N Y N - Y N Y NEffectsEffect 1 X XEffect 2 X X X
Combinations
X XX
X
Causes Values 1 2 3 4 5 6 7 8Cause 1 Y, N Y Y Y Y N N N NCause 2 Y, N Y Y N N Y Y N NCause 3 Y, N Y N - - Y N Y NEffectsEffect 1 X X XEffect 2 X X X
Combinations
Y N
X XX
X
Prof. Dr. Knut Hinkelmann 9MSc BIS/
Decision Trees
Decision trees are a graphical representation of rules Each inner node corresponds to a decision Each edge represents an alternative value for the decision The leaf nodes represent actions or effects
Deduciblemet?
no reimbursement
Type ofvisit
ParticipatingPhysician?
N
YL
H
DY
N 50%
90%
80%
70%
Prof. Dr. Knut Hinkelmann 11MSc BIS/
VisiRule – a graphical modelling tool
VisiRule™ is an extension to WIN-PROLOG from Logic Programming Associates Ltd.
VisiRule allows experts to build decision models using a graphical paradigm
VisiRule allow to graphically represent forward chaining rules with access to Prolog
VisiRule models can be interpreted and executed
VisiRule models can be exported to other programs and integrated into existing web and desktop standards
Prof. Dr. Knut Hinkelmann 12MSc BIS/
Layers of VisiRule
VisiRule creates charts (layer 1)
VisiRule generates Flex code (LPA ‘s Expert System Product) (layer 2)
Flex code in turn generates Prolog (layer 3)
The underlying Prolog allows to do almost anything, including call C functions using a built-in predicate called winapi/4
VisiRule
Flex
WIN-PROLOG
Integration with VB, Delphi, ODBC
Prof. Dr. Knut Hinkelmann 14MSc BIS/
A simple visible chart
Start node
Question
Expressions
End nodes
Prof. Dr. Knut Hinkelmann 16MSc BIS/
Question Types
Single Choice This is the default option. The menu produced will onlyallow the user to select one of the items on the menu.
Multiple Choice This allows the user to select any or none of the items on the menu.
Number Input Instead of a menu, this option provides an input box intowhich the user can enter any number
Integer Input This is like Number Input, but only allows the user to enteran integer.
Set Input An input box is also provided by this option. The user cantype in a list of items, separated by a space character. For example: red amber green.
Name Input Another input box is provided into which the user can typea word or phrase.
Prof. Dr. Knut Hinkelmann 17MSc BIS/
Generating and running executable code
To run a ruleset:• Right click in background• Select „Show Code …“• Click on [Run]
Prof. Dr. Knut Hinkelmann 18MSc BIS/
Generating and running executable code
Running a ruleset:• Questions are asked one after the other• Select the appropriate answer• The result is shown at the end
Prof. Dr. Knut Hinkelmann 19MSc BIS/
Representing a Decision in VisiRuleVisiRule diagrams are graphical representations of forward chaining rules:
Prof. Dr. Knut Hinkelmann 21MSc BIS/
Travel Advisory represented as Decision Table and Decision Tree
Prof. Dr. Knut Hinkelmann 23MSc BIS/
Dividing a Decision Tree into Subtrees usingContinuation Boxes (Cont.)
Prof. Dr. Knut Hinkelmann 24MSc BIS/
Statement Box
The function of a statement box is to calculate a value frominformation that is already known.
Statement boxes have three elements: an editable name (balance_plus_order in example below) an editable local variable (X in example below) a statement assigning a value to the variable using the operator
„is“ (X is balance + order_total.)(Note: On the right of „is“ there is editable Prolog code which isused to calculate the value