LC3-2009_-_SCCS451_-_C2_-_Rule_Based_Expert_System

advertisement
SCCS451 Artificial Intelligence
Week 3
Asst. Prof. Dr. Sukanya Pongsuparb
Dr. Srisupa Palakvangsa Na Ayudhya
Dr. Benjarath Pupacdi
1
Someone with
deep knowledge
and experience in
a particular
domain
Software
Program
Expert System
A software program with an expert’s knowledge and
experience, so it can help us like an expert can.
2
Knowledge is
An understanding of a subject or domain
The sum of what is currently known
An expert is
A person with deep knowledge / experience in some
specific domain
A skillful person who can do things that others cannot
An Expert’s Knowledge
Too complex to be thoroughly represented as an algorithm
Can be simply and effectively represented as rules
But, what are rules?
3
If the crossing light is red
then wait.
4
If the crossing light is green
then cross.
5
If the crossing light is red, then wait.
If the crossing light is green, then cross.
If <…>, then <…>.
Production Rule or Rule
6
In AI, rules are used as the most common knowledge
representation.
A rule can be defined as an IF-THEN structure.
Rules provide some description of how to solve a
problem.
Rules are relatively easy to create and understand.
7
≥1
≥1
IF <antecedent> THEN <consequent>
object
value
object
value
Examples:
• IF the crossing light is red THEN action is wait.
• IF ‘age of customer’ < 18
AND ‘cash withdrawal’ > 2000
THEN ‘parent signature’ is required
* antecedent == premise == condition
* consequent == conclusion == action
8
Recommendation
IF
AND
THEN
IF
AND
AND
AND
THEN
IF
AND
THEN
OR
customer bought “JAVA: How to program”
customer bought “Network Programming”
recommend “Java Servlet Programming”
the person has a fever
the person has a sore throat
Heuristic
the person is coughing
the person has a runny nose
the person has a cold
the car is dead
the fuel tank is empty
Directive
the action is refuel the car
the action is get a taxi
9
1. Relation
IF
the fuel tank is empty
THEN
the car is dead
2. Recommendation
IF
the season is autumn
AND
the sky is cloudy
AND
the forecast is drizzle
THEN
the advice is ‘take an umbrella’
3. Directive
IF
the car is dead
AND
the fuel tank is empty
THEN
the action is ‘refuel the car’
10
4. Strategy
IF
THEN
IF
AND
THEN
the car is dead
the action is ‘check out the fuel tank’;
step 1 is complete
step 1 is complete
the fuel tank is full
the action is ‘check the battery’;
step 2 is complete
5. Heuristic
IF
AND
AND
THEN
the spill is liquid
the spill pH < 6
the spill smell is vinegar
the spill material is acetic acid
11
Expert’s knowledge
is encoded into the
system via a set of
rules.
Someone with
deep knowledge
and experience in
a particular
domain
Software
Program
Rule-based Expert System
A software program with an expert’s knowledge and
experience, so it can help us like an expert can.
12
A computer program capable of performing at the level
of a human expert in a narrow problem area
The most popular expert systems are rule-based.
Applications in
Business
Engineering
Medicine
Geology
Let’s see some real-world examples
13
14
Domain
Expert
Programmer
Expert
System
End
User
15
Project Manager
Domain
Expert
Knowledge
Engineer
Programmer
Expert
System
End
User
16
Domain Expert
Most important player in the team
Knowledge Engineer
Design, build, and test the system
Pick/interact with the expert
Establish rules
Pick development team
Programmer – Actual coding of the system
Project Manager
Keep everything on schedule
Make sure all milestones are met
End User
Uses the system, e.g. doctors, chemists, etc.
Good user interface design is vital
17
An expert system with the knowledge removed
All the user has to do is to add the knowledge in the
form of rules and provide relevant data to solve the
problem.
So instead of picking a programmer, the knowledge
engineer may pick an expert system shell because the
system does not have to be coded. The engineer only
have to add the knowledge into the system.
For a small expert system, the project manager,
knowledge engineer, or even the expert can be the
same person.
18
Expert System Shell
19
A real-world example
20
Another real-world example
21
Project Manager
Domain
Expert
Knowledge
Engineer
Programmer
Expert
System
End
User
22
Long-term Memory
Short-term Memory
Production Rule
Fact
REASONING
Conclusion
A production system model
23
Knowledge Base
Database
Rule: IF-THEN
Fact
Inference Engine
Explanation Facilities
User Interface
User
24
Knowledge base
A set of rules obtained from the expert. When the
condition part a rule is satisfied, the rule fires and the
action part is executed.
Database
A set of facts used to match against the condition parts
of rules stored in the knowledge base
Inference Engine
Carries out reasoning until the system reaches a
solution. It links the facts with the rules.
25
Explanation facilities
Allow the user to ask the system how the conclusion is
reached and why a specific fact is needed
User Interface
Means of communication between a user seeking a
solution to a problem and an expert system
26
External
Database
External Program
Expert System
Knowledge Base
Database
Rule: IF-THEN
Fact
Inference Engine
Explanation Facilities
User Interface
User
Developer
Interface
Knowledge Engineer
Expert
27
External Interface
Allow the system to work with external files or
programs written in conventional languages
Developer Interface
Includes knowledge base editor, debugging aids,
tracing facilities
Runtime knowledge acquisition
Asks for needed information whenever it is not
available in the database. System continues when the
information is obtained.
28
An expert system is built to perform at a human expert
level in a narrow, specialized domain. Thus, the most
important characteristic of an expert system is its highquality performance. No matter how fast the system
can solve a problem, the user will not be satisfied if
the result is wrong.
On the other hand, the speed of reaching a solution is
very important. Even the most accurate decision or
diagnosis may not be useful if it is too late to apply,
for instance, in an emergency, when a patient dies or a
nuclear power plant explodes.
29
Expert systems apply heuristics to guide the reasoning
and thus reduce the search area for a solution.
A unique feature of an expert system is its explanation
capability. It enables the expert system to review its
own reasoning and explain its decisions.
Expert systems employ symbolic reasoning when
solving a problem. Symbols are used to represent
different types of knowledge such as facts, concepts
and rules.
30
An expert system is supposed to imitate a human
expert.
Can a human expert make a mistake?
A human expert is only a human after all.
A human expert can make a mistake. An incorrect rule
may be fed into the system.
Yes, expert systems can make mistakes.
31
In theory, a conventional program always give the
same correct solution.
But it can solve a problem if it has all the right data
built into it.
When the data is incomplete or contains errors, a
conventional program would provide no solution or an
incorrect one.
An expert system, on the other hand, can work when
the data is incomplete or fuzzy.
32
Expert systems can work when data is incomplete or
fuzzy. That is not the case for conventional programs.
In expert systems, knowledge is separated from its
processing.
Expert system shells are commonly used.
Experts systems are easier to build and maintain. Since
the knowledge and processing are separated, adding
new knowledge, i.e. new rules, can be as easy as
entering rules into a text editor.
33
Human Experts
Expert Systems
Conventional Programs
Use knowledge in the
form of rules of thumb or
heuristics to solve
problems in a narrow
domain.
Process knowledge
expressed in the form of
rules and use symbolic
reasoning to solve
problems in a narrow
domain.
Process data and use
algorithms, a series of
well-defined operations,
to solve general numerical
problems.
In a human brain,
knowledge exists in a
compiled form.
Provide a clear
separation of knowledge
from its processing.
Do not separate
knowledge from the
control structure to
process this knowledge.
Capable of explaining a
line of reasoning and
providing the details.
Trace the rules fired
during a problem-solving
session and explain how a
particular conclusion was
reached and why specific
data was needed.
Do not explain how a
particular result was
obtained and why input
data was needed.
34
Human Experts
Expert Systems
Conventional Programs
Use inexact reasoning and
can deal with incomplete,
uncertain and fuzzy
information.
Permit inexact reasoning
and can deal with
incomplete, uncertain and
fuzzy data.
Work only on problems
where data is complete
and exact.
Can make mistakes when
information is incomplete
or fuzzy.
Can make mistakes when
data is incomplete or
fuzzy.
Provide no solution at all,
or a wrong one, when data
is incomplete or fuzzy.
Enhance the quality of
problem solving via years
of learning and practical
training. This process is
slow, inefficient and
expensive.
Enhance the quality of
problem solving by
adding new rules or
adjusting old ones in the
knowledge base. When
new knowledge is
acquired, changes are
easy to accomplish.
Enhance the quality of
problem solving by
changing the program
code, which affects both
the knowledge and its
processing, making
changes difficult.
35
Expert’s knowledge
is encoded into the
system via a set of
rules.
Someone with
deep knowledge
and experience in
a particular
domain
Software
Program
Rule-based Expert System
A software program with an expert’s knowledge and
experience, so it can help us like an expert can.
36
Inference techniques are how an expert system uses
the rules to derive to a solution.
There are two common inference techniques
Forward chaining
Backward chaining
Today we will talk about
Forward Chaining.
37
Rule firing = adding an inferred fact to the database
Database
Fact: A is x
Fact: B is y
Fire
Knowledge Base
Rule: IF A is x THEN B is y
38
Inference chain = a sequence of the matching of the
rule IF parts
Database
Fact: A
Fact: C
Fact: B
Fact: D
Fact: E
Knowledge Base
Rule 1: Y & D  Z
Rule 2: X & B & E  Y
Rule 3: A  X
39
Inference chain = a sequence of the matching of the
rule IF parts
Database
Fact: A
Fact: C
Fact: B
Fact: D
Fact: E
Fact: X
Knowledge Base
Rule 1: Y & D  Z
Rule 2: X & B & E  Y
Rule 3: A  X
40
Inference chain = a sequence of the matching of the
rule IF parts
Database
Fact: A
Fact: C
Fact: B
Fact: D
Fact: E
Fact: X
Fact: Y
Knowledge Base
Rule 1: Y & D  Z
Rule 2: X & B & E  Y
Rule 3: A  X
41
Inference chain = a sequence of the matching of the
rule IF parts
Database
Fact: A
Fact: C
Fact: B
Fact: D
Fact: E
Conclusion is Z
Fact: X
Fact: Y
Knowledge Base
Rule 1: Y & D  Z
Rule 2: X & B & E  Y
Rule 3: A  X
42
Rule 1:
Rule 2:
Rule 3:
IF
Y is true
AND D is true
THEN Z is true
IF
AND
AND
THEN
X is true
B is true
E is true
Y is true
A
X
B
Y
Z
E
D
IF
A is true
THEN X is true
43
Forward chaining is the data-driven reasoning.
The reasoning starts from the known data and
proceeds forward with that data.
Each time only the topmost rule is executed.
When fired, the rule adds a new fact in the database.
Any rule can be executed only once.
The match-fire cycle stops when no further rules can
be fired or a goal is reached.
44
Database
A
B
C
D
Database
A
E
B
C
X
Match
Fire
Match
Database
D
E
X
L
Fire
A
B
Database
C
D
E
X
L
Y
Match
Fire
A
B
C
D
E
X
L
Y
Z
Match
Fire
Knowledge Base
Y&D
Z
Knowledge Base
Y&D
Z
Knowledge Base
Y&D
Z
Knowledge Base
Y&D
Z
X&B&E
A
C
L&M
X&B&E
A
C
L&M
X&B&E
A
C
L&M
X&B&E
A
C
L&M
Y
X
L
N
Cycle 1
Y
X
L
N
Cycle 2
Y
X
L
N
Y
X
L
N
Cycle 3
45
Forward chaining is a technique for gathering
information and then inferring from it whatever can be
inferred.
However, in forward chaining, many rules may be
executed that have nothing to do with the established
goal.
For example, CL
A real expert system has hundreds of rules. Some may
be unrelated to the goal, so forward chaining may not
be efficient.
46
Media Advisor Expert System
The system gives advice on selecting a medium for
delivering a training program based on the trainee’s
job.
47
Scenario 1:
Trainee is a mechanical technician who maintains a
hydraulic system.
System advices a workshop medium. The trainee could learn
how basic hydraulic components operate, how to trouble
shoot hydraulic problems as well as simple hydraulic repairs.
48
Scenario 2:
Trainee is an insurance clerk.
System advices a lecture/tutorial medium. The trainee could
learn from a classroom about the tasks as well as about real
applications.
49
IF
THEN
Rule #
Environment
Stimulus_situation
1
Papers ⋁Manuals ⋁ Documents ⋁ Textbooks
Verbal
2
Pictures ⋁ Illustrations ⋁ Photographs ⋁ Diagrams
Visual
3
Machines ⋁ Buildings ⋁ Tools
Physical Object
4
Numbers ⋁ Formulas ⋁ Computer Programs
Symbolic
Rule #
The Job
Stimulus_response
5
Lecturing ⋁ Advising ⋁ Counseling
Oral
6
Building ⋁ Repairing ⋁ Troubleshooting
Hands-on
7
Writing ⋁ Typing ⋁ Drawing
Documented
8
Evaluating ⋁ Reasoning ⋁ Investigating
Analytical
Knowledge Base
50
IF
⋀
⋀
THEN
Rule#
Stimulus_situation
Stimulus_response
Feedback
Medium
9
Physical_object
Hands_on
Required
Workshop
10
Symbolic
Analytical
Required
Lecture-tutorial
11
Visual
Documented
Not required
DVD
12
Visual
Oral
Required
Lecture-tutorial
13
Verbal
Analytical
Required
Lecture-tutorial
14
Verbal
Oral
Required
Role-play exercises
Knowledge Base
51
Q: What sort of environment is a trainee dealing with on
the job?
> machines
Knowledge Base
Rule #
Environment
Stimulus_situation
1
Papers ⋁Manuals ⋁ Documents ⋁ Textbooks
Verbal
2
Pictures ⋁ Illustrations ⋁ Photographs ⋁ Diagrams
Visual
3
Machines ⋁ Buildings ⋁ Tools
Physical Object
4
Numbers ⋁ Formulas ⋁ Computer Programs
Symbolic
Database
Fact: Environment is machines
Fact: Stimulus_situation is physical object
52
Q: In what way is a trainee expected to act on the job?
> repairing
Knowledge Base
Rule #
The Job
Stimulus_response
5
Lecturing ⋁ Advising ⋁ Counseling
Oral
6
Building ⋁ Repairing ⋁ Troubleshooting
Hands-on
7
Writing ⋁ Typing ⋁ Drawing
Documented
8
Evaluating ⋁ Reasoning ⋁ Investigating
Analytical
Database
Fact: Environment is machines
Fact: Stimulus_situation is physical object
Fact: The job is repairing
Fact: Stimulus_response is hands-on
53
Q: Is feedback on the trainee’s progress required during training?
> Yes
Rule#
Stimulus_situation
Knowledge Base
Stimulus_response
9
Physical_object
Hands_on
Required
Workshop
10
Symbolic
Analytical
Required
Lecture-tutorial
11
Visual
Not required
DVD
12
Visual
Oral
Required
Lecture-tutorial
13
Verbal
Analytical
Required
Lecture-tutorial
14
Verbal
Oral
Required
Role-play exercises
⋀
Documented
⋀
Feedback
Medium
Database
Fact: Environment is machines
Fact: The feedback is required
Fact: Stimulus_situation is physical object
Fact: The job is repairing
Fact: Stimulus_response is hands-on
54
Expert Systems
Rules
Rule-based Expert Systems
Developing an Expert System
Rule Inference
Forward Chaining
Next week we will cover backward chaining
55
Download