Sei sulla pagina 1di 25

Tutorial 1

Building Decision Tree


& Implementing in CLIPs

Tutor Information

Song Shen
PhD Candidate in Medical Informatics
Email: sson800@aucklanduni.ac.nz
Office hours: T.B.A.
If you have any questions regarding Tutorials
outside tutoring you may email me directly

Assignment Problems
Two tasks in this assignment:
- Modeling knowledge by using decision tree

- Implementing the modeled knowledge


(decision tree) in CLIPS

Task 1: Modeling knowledge by using


decision tree
Find a SIMPLE problem you can diagnosis
- e.g. I cans connect to Internet or choosing a mobile
phone

Diagnosis : is to use your experience (heuristic


knowledge) to analysis the problem and find out all
probable reasons causing the problem, then
accordingly give suggestions of how to resolve it.

Task 1: Modeling knowledge by using


decision tree
In Knowledge Modeling, decision tree has
> Root node : is decision node
> Node (parent node or child node) : is either decision node or
consequence node
> leaf node : is consequence node

decision node : is a symptom needed to be diagnosed


consequence node : is a suggestion outcome

Task 1: Modeling knowledge by using


decision tree
Procedure of building decision tree:
1.

Decide the perspective from which the diagnosis should be conducted.

2.

What is the fundamental symptom (root node) causing the problem from the
decided perspective.

3.

Define its constraints (e.g. yes/no) and analysis its all possible children nodes

4.

Add children nodes of the fundamental symptom into decision tree.


- probable symptoms (decision nodes)
- conclusions (consequence nodes)

5.

If any of children node is decision node, define its constraints and add its
children nodes into decision tree.

6.

Repeat step 5 until all leaf nodes are consequence nodes.

Task 1: Modeling knowledge by using


decision tree
Example:
>Problem:
car does not work properly!

>Perspectives of diagnosis:
- Tyre breakdown
- Mechanical breakdown
- Running out of petrol

Problem: car does not work properly!

Task 1: Modeling knowledge by using


decision tree
Example:
>Problem:
car does not work properly!

>Perspectives of diagnosis:
- Tyre breakdown
- Mechanical breakdown
- Running out of petrol

Problem: car does not work properly!


Perspective of diagnosis : Mechanical
breakdown

Task 1: Modeling knowledge by using


decision tree
Example:
>Problem:

Problem: car does not work properly!

car does not work properly!

Perspective of diagnosis : Mechanical


breakdown

>Perspectives of diagnosis:

Fundamental symptom : Car does not


start! (root node)

- Tyre breakdown
- Mechanical breakdown
- Running out of petrol

Task 1: Modeling knowledge by using


decision tree
Example:
>Problem:

Problem: car does not work properly!

car does not work properly!

Perspective of diagnosis : Mechanical


breakdown

>Perspectives of diagnosis:

Fundamental symptom : Car does not


start! (root node)

- Tyre breakdown
- Mechanical breakdown
- Running out of petrol

Constraints : yes or no

Task 1: Modeling knowledge by using


decision tree
Example:
>Problem:

Problem: car does not work properly!

car does not work properly!

Perspective of diagnosis : Mechanical


breakdown

>Perspectives of diagnosis:

Fundamental symptom : Does car start?


(root node)

- Tyre breakdown
- Mechanical breakdown
- Running out of petrol

Constraints : yes or no
Constraint = yes ==> just didnt turn car on
Constraint = no ==> starter motor turns?

Task 1: Modeling knowledge by using


decision tree
Here, we get the root node and two children nodes of
root node (consequence node and decision node)

Now lets work on diagnosis of the decision node


starter motor turns?
> to define this decision nodes constraints and find its children nodes
(decision nodes or consequence nodes) corresponding to its constraint
values.

Task 1: Modeling knowledge by using


decision tree
Diagnose decision node starter motor turns?, we
get two decision nodes as its children nodes.

Task 1: Modeling knowledge by using


decision tree
Iterate diagnosis of children nodes till all leaf nodes are
consequence nodes and then decision tree is built.

Task 1: Modeling knowledge by using


decision tree
Note
- Specify problem domain
> comments on decision tree diagram
> or comments in the code
> or banner displayed when running code

- Create your own decision tree

Consequence
node

Decision
nodes

ts

at least one decision


nodes children are
also decision nodes
ts

No less than 8
decision nodes

ts

Every consequence
node should be
reachable in your
implemented expert
system
ts

Task 1: Modeling knowledge by using


decision tree
Something Extra
Build a real graph
- look less like a sequential flowchart
- e.g. at least one or two parent nodes have two or more decision
nodes as children nodes

More than two choices for at least one decision


node
- not only yes/no constraints
- e.g. weather = sunny or cloudy or rainy

Task 2: Implementing decision tree in


CLIPS
CLIPS :
- stands for C Language Integrated Production System
- a free expert system shell distributed by NASA from 1985 to 1998.
- general-purpose problem-solving "engine
- like other expert system languages, CLIPS deals with rules and facts
-Statements start with left bracket ( and terminated with right
bracket )

Task 2: Implementing decision tree in


CLIPS
Where to download CLIPS:
http://clipsrules.sourceforge.net/
For example, to wins user:
-> in the link above, click
CLIPS 6.3 Beta for Windows Release 3
-> click SourceForge CLIPS Download Page.
-> there is a list of .zip files , download
windows_executables_624.zip
-> decompose the zip file, click CLIPWin.exe
-> and here we go!

Task 2: Implementing decision tree in


CLIPS

Task 2: Implementing decision tree in


CLIPS
Some useful functions
Read Value:
(bind <variable> <expression>*)

IF-THEN-ELSE:
(if <expression>
then <action>*
[else <action>*])

Task 2: Implementing decision tree in


CLIPS
Note
It is OK to reuse or modify an example CLIP code!

Please do remember to reference the reused or


modified source code.

-e.g. adapted from auto.clp or modified from example.clp

Potrebbero piacerti anche