You are on page 1of 35

Expert System Part 2

Prepared By Zahriah Sahri

1
Expert System Main Components
and Human Interfaces

Still at this topic

Inference
Engine

Expert System
2
How to Build Knowledge base for
Expert System?

Knowledge
Acquisition

Knowledge
Representation
Knowledge Representation
Definition:-
the method used to encode knowledge in an
intelligent systems knowledge base.
Objective:-
to express the acquired knowledge in computer-
tractable form, such that it can be used to help
expert systems making decision.

4
Knowledge Representation

Logical Rules
Representation

Object Techniques
Attribute Semantic
Value Networks

Frames
5
Knowledge Representation
Object-Attribute Value

Simple way to store facts.


Each fact about a set of objects is set out systematically in
columns.
Little opportunity for inference.

6
Knowledge Representation
Logical Representation
represent knowledge, using mathematical or orthographic
symbols, inference rules and are based on precisely defined
syntax and semantics.

Logical
Representations

Higher Order
Predicate
Logic
Logic
First Order Proportional
Logic Logic

7
Knowledge Representation
Semantic Network
is a formal graphic language representing
facts about entities about which we could
reason.

8
Knowledge Representation
Semantic Network

How tall is Steve?

9
Knowledge Representation
Semantic Network

Jason is 15, Bryan is 40, Arthur is 70, Jim is 74


How old is Julia?
Knowledge Representation
Semantic Network

Because the syntax is the same


We can guess that Julias age is similar to Bryans
Formalism imposes restricted syntax
Knowledge Representation
Frames
represent an alternative way to structure
and organize knowledge.
A frame system is a hierarchy of frames.
Each frame has:
a name;
slots: properties of the entity that has the
name, and their values.
12
Knowledge Representation
Frames

13
Knowledge Representation
Rules
based on the general underlying idea of condition-
action pairs (also called if-then pairs, production
rules, or just plain productions).
- A production rule is written in the form
- if this condition holds, then this action is
appropriate.

they are capable of modelling any computable


procedure.

14
Knowledge Representation

Rules -Syntax
(rule (name)
(if (trigger fact 1) (trigger fact 2)
:
:
(trigger fact n))
(then (conclusion fact 1, or action 1 )
(conclusion fact 2, or action 2)
:
:
(conclusion fact n, or action n)))
Knowledge Representation
Rules Example
Rule 1:if
the engine is getting gas, and
the engine will turn over,
then
the problem is spark plugs.
Rule 2:if
the engine does not turn over, and
the lights do not come on
then
the problem is battery or cables.
Rule 3:if
the engine does not turn over, and
the lights do come on
then
the problem is the starter motor.
Rule 4:if
there is gas in the fuel tank, and
there is gas in the carburator
then 16

the engine is getting gas.


Expert System Main Components
and Human Interfaces

Inference Lets learn


Engine

Expert System
17
Inference Engine
Inference engine - draws conclusions from
the knowledge base.
Example of drawing to conclusion:-
If I tell you:
All boys have a mother
and that:
"John is a boy"

What can you tell me about John ? You are able to figure out

that:
"John has a mother
without being explicitly told this fact.

18
Inference Engine

For this course, we will learn how to


infer using knowledge that is
represented in RULES.

Expert systems that store RULES in


their knowledge base are called
RULES-based Expert System

19
Inference Engine
For a knowledge base which knowledge is
represented by rules, then forward chaining
and backward chaining are used to draw
conclusions.
Inference engine, it cycles through three
steps:
match facts against rules
select a rule
execute the rule
20
Inference Engine
Forward chaining (data-driven)
start with facts and use rules to draw conclusions/take
actions.
best for prognosis, monitoring, and control.
Examples: CLIPS, OPS5
Backward chaining (query driven) start
work backward from the goal/decision and look for rules
that can provided the desired goal/decision
best for diagnosis problems.
Examples: MYCIN
21
Inference Engine
Forward-chaining Example (A,B,D, and E are given)
If A then X
If X and B and E then Y
If Y and D then Z
If C then L
If L and M then N Not fired (executed)

22
Inference Engine
Forward-chaining - Example

23
Inference Engine
Backward-chaining Example (A,B,C, D and E are
given)
If Y and D then Z
If X and B and E then Y
If A then X
If C then L
Not fired (executed)
If L and M then N

24
Inference Engine
Backward-chaining Example

25
Inference Engine
Forward-Chaining or Backward-Chaining
which to use?
What do experts use?
Are we trying to prove a particular
decision?
Backward-Chaining
Are we trying to find all possible
solutions?
Forward-Chaining

26
Example Expert System

This is an example expert system built to


help show a user their potential risk of
contracting colon cancer based on their
lifestyle and family history.
http://www.barisoft.com/mycancercheck/
Example System
OBJECT NUMBER 21
Name: [Age_Related]
Prompt: How OLD were you when you were FIRST diagnosed with any of the other related cancer?
Max. selections: 100
Legal Values:
-0
-----------------

OBJECT NUMBER 22
Name: {orc_age_rpt}
Prompt: Please enter a value for the ORC_AGE_RPT.
Max. selections: open
Legal Values:
-OPEN STRING
-----------------

OBJECT NUMBER 23
Name: Two_Related_Cancers
Prompt: Have you ever been diagnosed with any TWO or more of the following cancers? Colon, Gastric, Small Bowel, Hepatobiliary, Pancreatic, Endometrial, Ovarian, Ren
pelvis, or Ureter.
Max. selections: 1
Legal Values:
-Yes
-No
-----------------

OBJECT NUMBER 24
Name: {Non_Related_Cancers}
Prompt: Please enter any additional CANCERS for which YOU have been diagnosed. Example: Breast, Lymphoma. If no other cancers, then type None.
Max. selections: open
Legal Values:
Example System (contd)
* * * * RULES SUMMARY * * * *

No. of rules defined: 129

RULE NUMBER 1:disclaimer-no


IF
Disclaimer=No - I do not agree to the terms and conditions in the disclaimer
THEN
{status}=stop program
!Action=!LOOP

RULE NUMBER 2:disclaimer-yes


IF
Disclaimer=Yes - I have read the disclaimer and agree to all of its terms and conditions
THEN
{status}=continue with program

RULE NUMBER 3:Object Initialization


IF
THEN
[LS_Score]=0

RULE NUMBER 4:BMI Calculation


IF
[height]==!NOTBLANK
[weight]==!NOTBLANK
THEN
[bmi]=([weight]*703)/([height]*[height])
More Rules for the Example System
RULE NUMBER 123:Calc Greater Next or Suggested
IF
[age]==!NOTBLANK
[Suggested_Screen_Age]==!NOTBLANK
[Next_Scrn_Age]==!NOTBLANK
THEN
[Dif_Next]=[Next_Scrn_Age]-[Suggested_Screen_Age]

RULE NUMBER 124:If Next later than Suggested


IF
[Dif_Next]=>0
THEN
[Age_Difference]=[age]-[Next_Scrn_Age]

RULE NUMBER 125:If Next less or equal Suggested


IF
[Dif_Next]=<1
THEN
[Age_Difference]=[age]-[Suggested_Screen_Age]

RULE NUMBER 126:Get1stScrn Now


IF
[Age_Difference]==0
THEN
{screening_rec_age_rpt}=Schedule Screening Now at Age ([age]).
[Get_Screened_Age]=[age]
Guidelines to determine whether a problem is
appropriate for expert system solution:

1. The need for the solution justifies the cost and effort of building an
expert system.

2. Human expertise is not available in all situations where it is needed.

3. The problem may be solved using symbolic reasoning.

4. The problem domain is well structured and does not require


commonsense reasoning.

5. The problem may not be solved using traditional computing


methods.

6. Cooperative and articulate experts exist.

7. The problem is of proper size and scope.


Luger: Artificial Intelligence, 6th edition. Pearson Education Limited, 2009
3
Strength of Expert Systems
Provide consistent answers for repetitive decisions,
processes and tasks.
Hold and maintain significant levels of information.
Reduce employee training costs
Centralize the decision making process.
Create efficiencies and reduce the time needed to solve
problems.
Combine multiple human expert intelligences
Reduce the amount of human errors.
Give strategic and comparative advantages creating entry
barriers to competitors
Review transactions that human experts may overlook.
Weaknesses of Expert Systems
Require a lot of detailed knowledge
Restrict knowledge domain
Not all domain knowledge fits rule format
Expert consensus must exist
Experts cannot always clearly explain their logic and
reasoning.
Knowledge acquisition is time consuming
Challenges of automating complex processes.
Lack of flexibility and ability to adapt to changing
environments.
Not being able to recognize when no answer is
available.
Conclusions

Very interesting field of AI.


Expert Systems are extremely useful in the right
domain.
They are inflexible and require a lot of
collaboration between a knowledge engineer and
a domain expert.
When implemented correctly, expert systems
remove human error from the equation.
35