Decision Tree Clips

Embed Size (px)

Citation preview

  • 7/26/2019 Decision Tree Clips

    1/25

    Tutorial 1

    Building Decision Tree

    & Implementing in CLIPs

  • 7/26/2019 Decision Tree Clips

    2/25

    Tutor Information

    Song Shen

    PhD Candidate in Medical Informatics

    Email: [email protected] Office hours: T.B.A.

    If you have any questions regarding Tutorials

    outside tutoring you may email me directly

    mailto:[email protected]:[email protected]
  • 7/26/2019 Decision Tree Clips

    3/25

    Assignment Problems

    Two tasks in this assignment:

    - Modeling knowledge by using decision tree

    - Implementing the modeled knowledge

    (decision tree) in CLIPS

  • 7/26/2019 Decision Tree Clips

    4/25

    Task 1: Modeling knowledge by using

    decision tree

    Find a SIMPLE problem you can diagnosis

    - e.g. Icans connect to Internet or choosinga mobilephone

    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.

  • 7/26/2019 Decision Tree Clips

    5/25

    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

  • 7/26/2019 Decision Tree Clips

    6/25

    Task 1: Modeling knowledge by using

    decision treeProcedure 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 itschildren nodes into decision tree.

    6. Repeat step 5 until all leaf nodes are consequence nodes.

  • 7/26/2019 Decision Tree Clips

    7/25

    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!

  • 7/26/2019 Decision Tree Clips

    8/25

    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

    Perspective of diagnosis : Mechanical

    breakdown

    Problem: car does not work properly!

  • 7/26/2019 Decision Tree Clips

    9/25

    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

    Perspective of diagnosis : Mechanical

    breakdown

    Fundamental symptom : Car does not

    start! (root node)

    Problem: car does not work properly!

  • 7/26/2019 Decision Tree Clips

    10/25

    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

    Perspective of diagnosis : Mechanical

    breakdown

    Fundamental symptom : Car does not

    start! (root node)

    Problem: car does not work properly!

    Constraints : yes or no

  • 7/26/2019 Decision Tree Clips

    11/25

    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

    Perspective of diagnosis : Mechanical

    breakdown

    Fundamental symptom : Does car start?

    (root node)

    Problem: car does not work properly!

    Constraints : yes or no

    Constraint = yes ==> just didnt turn car on

    Constraint = no ==> starter motor turns?

  • 7/26/2019 Decision Tree Clips

    12/25

    Task 1: Modeling knowledge by using

    decision tree

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

    Now lets work on diagnosis of the decision node starter motor turns?

    > to define this decision nodesconstraints and find its children nodes(decision nodes or consequence nodes) corresponding to its constraint

    values.

  • 7/26/2019 Decision Tree Clips

    13/25

    Task 1: Modeling knowledge by using

    decision tree

    Diagnose decision node starter motor turns?, we

    get two decision nodes as its children nodes.

  • 7/26/2019 Decision Tree Clips

    14/25

    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.

  • 7/26/2019 Decision Tree Clips

    15/25

    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

  • 7/26/2019 Decision Tree Clips

    16/25

    ts

    Decision

    nodes

    Consequence

    node

  • 7/26/2019 Decision Tree Clips

    17/25

    ts

    at least one decision

    nodes children are

    also decision nodes

  • 7/26/2019 Decision Tree Clips

    18/25

    ts

    No less than 8

    decision nodes

  • 7/26/2019 Decision Tree Clips

    19/25

    ts

    Every consequence

    node should be

    reachable in your

    implemented expertsystem

  • 7/26/2019 Decision Tree Clips

    20/25

    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 decisionnodes 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

  • 7/26/2019 Decision Tree Clips

    21/25

    Task 2: Implementing decision tree in

    CLIPS

    CLIPS :

    - stands for CLanguage 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 rightbracket )

  • 7/26/2019 Decision Tree Clips

    22/25

    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!

    http://clipsrules.sourceforge.net/http://clipsrules.sourceforge.net/Version63Beta.htmlhttp://sourceforge.net/project/showfiles.php?group_id=215471&package_id=260062http://sourceforge.net/projects/clipsrules/files/CLIPS/6.24/windows_executables_624.zip/downloadhttp://sourceforge.net/projects/clipsrules/files/CLIPS/6.24/windows_executables_624.zip/downloadhttp://sourceforge.net/project/showfiles.php?group_id=215471&package_id=260062http://sourceforge.net/project/showfiles.php?group_id=215471&package_id=260062http://sourceforge.net/project/showfiles.php?group_id=215471&package_id=260062http://clipsrules.sourceforge.net/Version63Beta.htmlhttp://clipsrules.sourceforge.net/
  • 7/26/2019 Decision Tree Clips

    23/25

    Task 2: Implementing decision tree in

    CLIPS

  • 7/26/2019 Decision Tree Clips

    24/25

    Task 2: Implementing decision tree in

    CLIPS

    Some useful functions

    Read Value:

    (bind *)

    IF-THEN-ELSE:

    (if

    then*[else *])

  • 7/26/2019 Decision Tree Clips

    25/25

    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