chap 2: rule-based expert systems

55
1 Chap 2: Rule-Based Expert Systems Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi SCCS451 Artificial Intelligence Week 3

Upload: jude

Post on 23-Feb-2016

81 views

Category:

Documents


2 download

DESCRIPTION

Chap 2: Rule-Based Expert Systems. SCCS451 Artificial Intelligence Week 3. Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi. Someone with deep knowledge and experience in a particular domain. Software Program. Expert System. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chap 2: Rule-Based Expert Systems

1

Chap 2: Rule-Based Expert Systems

Asst. Prof. Dr. Sukanya PongsuparbDr. Srisupa Palakvangsa Na AyudhyaDr. Benjarath Pupacdi

SCCS451 Artificial IntelligenceWeek 3

Page 2: Chap 2: Rule-Based Expert Systems

2

Expert System

Someone with deep knowledge and experience in a particular domain

Software Program

A software program with an expert’s knowledge and experience, so it can help us like an expert can.

Page 3: Chap 2: Rule-Based Expert Systems

3

An Expert’s Knowledge

Knowledge isAn understanding of a subject or domainThe sum of what is currently known

An expert isA person with deep knowledge / experience in some specific domainA skillful person who can do things that others cannot

An Expert’s KnowledgeToo complex to be thoroughly represented as an algorithmCan be simply and effectively represented as rules

But, what are rules?

Page 4: Chap 2: Rule-Based Expert Systems

4

If the crossing light is red

then wait.

Page 5: Chap 2: Rule-Based Expert Systems

5

If the crossing light is green

then cross.

Page 6: Chap 2: Rule-Based Expert Systems

6

If the crossing light is red, then wait.

If the crossing light is green, then cross.

If <…>, then <…>.

Production Rule or Rule

Page 7: Chap 2: Rule-Based Expert Systems

7

Rules as a Knowledge Representation Technique

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.

Page 8: Chap 2: Rule-Based Expert Systems

8

A Basic Syntax of a Rule

IF <antecedent> THEN <consequent>

* antecedent == premise == condition* consequent == conclusion == action

≥ 1≥ 1

valueobject valueobject

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

Page 9: Chap 2: Rule-Based Expert Systems

9

More Rule Examples

IF customer bought “JAVA: How to program”AND customer bought “Network Programming”THEN recommend “Java Servlet Programming”IF the person has a feverAND the person has a sore throatAND the person is coughingAND the person has a runny noseTHEN the person has a coldIF the car is deadAND the fuel tank is emptyTHEN the action is refuel the carOR the action is get a taxi

Recommendation

Heuristic

Directive

Page 10: Chap 2: Rule-Based Expert Systems

10

Different Types of Rules1. Relation

IF the fuel tank is emptyTHEN the car is dead

2. RecommendationIF the season is autumnAND the sky is cloudyAND the forecast is drizzleTHEN the advice is ‘take an umbrella’

3. DirectiveIF the car is deadAND the fuel tank is emptyTHEN the action is ‘refuel the car’

Page 11: Chap 2: Rule-Based Expert Systems

11

Different Types of Rules – cont.4. Strategy

IF the car is deadTHEN the action is ‘check out the fuel tank’;

step 1 is completeIF step 1 is completeAND the fuel tank is fullTHEN the action is ‘check the battery’;

step 2 is complete5. Heuristic

IF the spill is liquidAND the spill pH < 6AND the spill smell is vinegarTHEN the spill material is acetic acid

Page 12: Chap 2: Rule-Based Expert Systems

12

Rule-based Expert System

Someone with deep knowledge and experience in a particular domain

Software Program

A software program with an expert’s knowledge and experience, so it can help us like an expert can.

Expert’s knowledge is encoded into the system via a set of rules.

Page 13: Chap 2: Rule-Based Expert Systems

13

Rule-based Expert System

A computer program capable of performing at the level of a human expert in a narrow problem areaThe most popular expert systems are rule-based.Applications in

BusinessEngineeringMedicineGeology

Let’s see some real-world examples

Page 14: Chap 2: Rule-Based Expert Systems

14

Page 15: Chap 2: Rule-Based Expert Systems

15

In developing an expert system…

Domain

Expert

End User

Programmer

Expert System

Page 16: Chap 2: Rule-Based Expert Systems

16

In developing an expert system…

Domain

Expert

End User

Programmer

Expert System

Knowledge Engineer

Project Manager

Page 17: Chap 2: Rule-Based Expert Systems

17

Expert System Development TeamDomain Expert

Most important player in the teamKnowledge Engineer

Design, build, and test the systemPick/interact with the expertEstablish rulesPick development team

Programmer – Actual coding of the systemProject Manager

Keep everything on scheduleMake sure all milestones are met

End UserUses the system, e.g. doctors, chemists, etc.Good user interface design is vital

Page 18: Chap 2: Rule-Based Expert Systems

18

Expert System Shell

An expert system with the knowledge removedAll 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.

Page 19: Chap 2: Rule-Based Expert Systems

19

Expert System Shell

Page 20: Chap 2: Rule-Based Expert Systems

20

A real-world example

Page 21: Chap 2: Rule-Based Expert Systems

21

Another real-world example

Page 22: Chap 2: Rule-Based Expert Systems

22

A closer look at a rule-based expert system…

Domain

Expert

End User

Programmer

Expert System

Knowledge Engineer

Project Manager

Page 23: Chap 2: Rule-Based Expert Systems

23

Conclusion

REASONING

Long-term Memory

ProductionRule

Short-term Memory

Fact

A production system model

Basic Structure of a rule-based expert system

Page 24: Chap 2: Rule-Based Expert Systems

24

Basic Structure of a rule-based expert system

Inference Engine

Knowledge Base

Rule: IF-THEN

Database

Fact

Explanation Facilities

User Interface

User

Page 25: Chap 2: Rule-Based Expert Systems

25

Basic Structure of a rule-based expert system

Knowledge baseA set of rules obtained from the expert. When the condition part a rule is satisfied, the rule fires and the action part is executed.DatabaseA set of facts used to match against the condition parts of rules stored in the knowledge baseInference EngineCarries out reasoning until the system reaches a solution. It links the facts with the rules.

Page 26: Chap 2: Rule-Based Expert Systems

26

Basic Structure of a rule-based expert system

Explanation facilitiesAllow the user to ask the system how the conclusion is reached and why a specific fact is neededUser InterfaceMeans of communication between a user seeking a solution to a problem and an expert system

Page 27: Chap 2: Rule-Based Expert Systems

27

Complete Structure of a Rule-based Expert System

User

ExternalDatabase External Program

Inference Engine

Knowledge Base

Rule: IF-THEN

Database

Fact

Explanation Facilities

User Interface DeveloperInterface

Expert System

Expert

Knowledge Engineer

Page 28: Chap 2: Rule-Based Expert Systems

28

Complete Structure of a Rule-based Expert System

External InterfaceAllow the system to work with external files or programs written in conventional languagesDeveloper InterfaceIncludes knowledge base editor, debugging aids, tracing facilitiesRuntime knowledge acquisitionAsks for needed information whenever it is not available in the database. System continues when the information is obtained.

Page 29: Chap 2: Rule-Based Expert Systems

29

Characteristics of an Expert System

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 high-quality 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.

Page 30: Chap 2: Rule-Based Expert Systems

30

Characteristics of an Expert System

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.

Page 31: Chap 2: Rule-Based Expert Systems

31

Can expert systems make mistakes?

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.

Page 32: Chap 2: Rule-Based Expert Systems

32

So conventional programs are better?

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.

Page 33: Chap 2: Rule-Based Expert Systems

33

2 Main Differences between Expert Systems and Conventional Programs

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.

Page 34: Chap 2: Rule-Based Expert Systems

34

Comparison - 1

Human Experts Expert Systems Conventional Programs

Use knowledge in theform of rules of thumb orheuristics to solveproblems in a narrowdomain.

Process knowledgeexpressed in the form ofrules and use symbolicreasoning to solveproblems in a narrowdomain.

Process data and usealgorithms, a series ofwell-defined operations,to solve general numericalproblems.

In a human brain,knowledge exists in acompiled form.

Provide a clearseparation of knowledgefrom its processing.

Do not separateknowledge from thecontrol structure toprocess this knowledge.

Capable of explaining aline of reasoning andproviding the details.

Trace the rules firedduring a problem-solvingsession and explain how aparticular conclusion wasreached and why specificdata was needed.

Do not explain how aparticular result wasobtained and why inputdata was needed.

Page 35: Chap 2: Rule-Based Expert Systems

35

Comparison - 2

Human Experts Expert Systems Conventional Programs

Use inexact reasoning andcan deal with incomplete,uncertain and fuzzyinformation.

Permit inexact reasoningand can deal withincomplete, uncertain andfuzzy data.

Work only on problemswhere data is completeand exact.

Can make mistakes wheninformation is incompleteor fuzzy.

Can make mistakes whendata is incomplete orfuzzy.

Provide no solution at all,or a wrong one, when datais incomplete or fuzzy.

Enhance the quality ofproblem solving via yearsof learning and practicaltraining. This process isslow, inefficient andexpensive.

Enhance the quality ofproblem solving byadding new rules oradjusting old ones in theknowledge base. Whennew knowledge isacquired, changes areeasy to accomplish.

Enhance the quality ofproblem solving bychanging the programcode, which affects boththe knowledge and itsprocessing, makingchanges difficult.

Page 36: Chap 2: Rule-Based Expert Systems

36

Rule-based Expert System

Someone with deep knowledge and experience in a particular domain

Software Program

A software program with an expert’s knowledge and experience, so it can help us like an expert can.

Expert’s knowledge is encoded into the system via a set of rules.

Page 37: Chap 2: Rule-Based Expert Systems

37

How does the system use the rules?

Inference techniques are how an expert system uses the rules to derive to a solution.There are two common inference techniques

Forward chainingBackward chaining

Today we will talk about Forward Chaining.

Page 38: Chap 2: Rule-Based Expert Systems

38

First, some terminologiesRule firing = adding an inferred fact to the database

Rule: IF A is x THEN B is y

Database

Knowledge Base

Fact: A is xFact: B is y

Fire

Page 39: Chap 2: Rule-Based Expert Systems

39

Some terminologies (Cont.)Inference chain = a sequence of the matching of the rule IF parts

Rule 1: Y & D ZRule 2: X & B & E YRule 3: A X

Database

Knowledge Base

Fact: A

Fact: B

Fact: C

Fact: DFact: E

Page 40: Chap 2: Rule-Based Expert Systems

40

Some terminologies (Cont.)Inference chain = a sequence of the matching of the rule IF parts

Rule 1: Y & D ZRule 2: X & B & E YRule 3: A X

Database

Knowledge Base

Fact: A

Fact: B

Fact: C

Fact: DFact: E Fact: X

Page 41: Chap 2: Rule-Based Expert Systems

41

Some terminologies (Cont.)Inference chain = a sequence of the matching of the rule IF parts

Rule 1: Y & D ZRule 2: X & B & E YRule 3: A X

Database

Knowledge Base

Fact: A

Fact: B

Fact: C

Fact: DFact: E Fact: X

Fact: Y

Page 42: Chap 2: Rule-Based Expert Systems

42

Some terminologies (Cont.)Inference chain = a sequence of the matching of the rule IF parts

Rule 1: Y & D ZRule 2: X & B & E YRule 3: A X

Database

Knowledge Base

Fact: A

Fact: B

Fact: C

Fact: DFact: E Fact: X

Fact: Y

Conclusion is Z

Page 43: Chap 2: Rule-Based Expert Systems

43

Inference Chain

Rule1: IF Y is trueAND D is trueTHEN Z is true

Rule2: IF X is trueAND B is trueAND E is trueTHEN Y is true

Rule3: IF A is trueTHEN X is true

A X

B

E

Y

DZ

Page 44: Chap 2: Rule-Based Expert Systems

44

Forward Chaining

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.

Page 45: Chap 2: Rule-Based Expert Systems

45

Forward Chaining

Match Fire Match Fire Match Fire Match FireKnowledge Base

Database

A C E

X

Database

A C E

L

Database

A D

YL

B

X

Database

A D

ZY

B

LX

Cycle 1 Cycle 2 Cycle 3

X & B & EZY & D

LCL & M

A X

N

X & B & EZY & D

LCL & M

A X

N

X & B & EZY & D

LCL & M

A X

N

X & B & EZY & D

LCL & M

A X

N

Knowledge Base Knowledge Base Knowledge Base

X

C E C EB D B D

Y Y Y Y

Page 46: Chap 2: Rule-Based Expert Systems

46

Forward Chaining

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, CLA real expert system has hundreds of rules. Some may be unrelated to the goal, so forward chaining may not be efficient.

Page 47: Chap 2: Rule-Based Expert Systems

47

Forward Chaining Exercise

Media Advisor Expert System

The system gives advice on selecting a medium for delivering a training program based on the trainee’s job.

Page 48: Chap 2: Rule-Based Expert Systems

48

Media Advisor Expert System

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.

Page 49: Chap 2: Rule-Based Expert Systems

49

Media Advisor Expert System

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.

Page 50: Chap 2: Rule-Based Expert Systems

50

Media Advisor Expert System: Rules 1 – 8

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

IF THEN

Knowledge Base

Page 51: Chap 2: Rule-Based Expert Systems

51Knowledge Base

Media Advisor Expert System: Rules 9 – 14

IF

THENRule# 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

⋀ ⋀

Page 52: Chap 2: Rule-Based Expert Systems

52

Media Advisor Expert System in Action

Q: What sort of environment is a trainee dealing with on the job?

> machines

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

DatabaseFact: Environment is machines

Fact: Stimulus_situation is physical object

Knowledge Base

Page 53: Chap 2: Rule-Based Expert Systems

53

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

Media Advisor Expert System in Action

Q: In what way is a trainee expected to act on the job? > repairing

DatabaseFact: Environment is machines

Fact: Stimulus_situation is physical object

Knowledge Base

Fact: The job is repairing Fact: Stimulus_response is hands-on

Page 54: Chap 2: Rule-Based Expert Systems

54

Media Advisor Expert System in ActionQ: Is feedback on the trainee’s progress required during training? > Yes

DatabaseFact: Environment is machines

Fact: Stimulus_situation is physical object

Fact: The job is repairing Fact: Stimulus_response is hands-on

Fact: The feedback is required

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

⋀ ⋀

Page 55: Chap 2: Rule-Based Expert Systems

55

Recap today

Expert SystemsRulesRule-based Expert SystemsDeveloping an Expert SystemRule InferenceForward ChainingNext week we will cover backward chaining