expert systems - École mohammadia d'ingénieurs...• r1 if animal has feathers then animal is...

32
Artificial Intelligence Lecture 4 Karim Bouzoubaa Expert Systems

Upload: others

Post on 04-Dec-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence

Lecture 4 Karim Bouzoubaa

Expert Systems

Page 2: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 2

Introduction

¢  ES: Capture, represent, store and apply human K using a machine l  Practical way to build automated experts (where there is a

need for practical experience)

¢  Application areas

l  Medicine

l  Management (Banking, Finance, Marketing)

l  Mineral prospecting

Page 3: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 3

General Architecture

¢ Traditional software

¢ KB software

Data And

results

Prog

(set of procedures)

KB

Inference Engine (exploitation

mechanism of the K)

Page 4: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 4

Reasoning withIN ES

¢  Expert systems have been developed in the 1970s as practical systems to reason on knowledge in terms of rules and facts as flat databases (triplets)

¢  In the 1980s other ideas, i.e. semantic nets, frames, etc.

¢  An expert system is an automatic reasoner that is based on the logic inference rule called Modus Ponens

Page 5: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 5

Detailed Architecture

¢  The inference engine is the reasoning module which uses Modus Ponens IF P(x) Then Q(x) rule

P(a) fact

----------------- (inference)

Q(a) deduced fact

¢  The inference engine matches facts (P(a)) and rule premises (IF P(x)) to deduce new facts Q(a)

¢  It also chains rules: IF P Then Q and IF Q Then R

Page 6: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 6

Detailed Architecture

¢  UI l  Facilitate the dialogue (NL, graphical, etc.) l  System Explanation l  Justifies conclusions

¢  KB l  Production rules

¢  IE l  Modes of reasoning l  Filtering l  Choice of Rules

Page 7: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 7

KB ¢  K in the form of production rules

¢  Transferring a specialist's K to a machine

¢  Difficulty: Expert K's are very diverse l  His way of reasoning l  Making decisions l  To make a diagnosis l  To gain experience

¢  Formalism 'Rule of production' is the most used l  Cause: Experts tend to express K in form: situation -> action

Page 8: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 8

KB

¢  Some examples of rules IF an animal is of a given species AND this animal has children

THEN children are of the same species IF start time work > 7 pm AND finishing hour < 7 am THEN work schedule = night time

Page 9: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 9

KB ¢  The + of this formalism

l  Express very varied K l  Declarative K l  Rules are independent

•  KB consists of granules of K

¢  Various types of information l  Inferences resulting from specific observations l  Abstraction, generalizations and categorization of data l  Conditions necessary to achieve a goal l  Strategies to eliminate uncertainty l  Probable causes of symptoms

Page 10: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 10

KB ¢  K in the form of schemas

l  Frame: structure to describe an object

¢  The + of this formalism

l  Lets translate the typical way experts organize most of their K l  Provides a structured representation of relationships between objects l  Supports a concise technique of definition by specialization that is easy to

implement for most experts l  Sharing information between multiple schemas (inheritance) l  Procedural Attachment

¢  The - of this formalism

l  No direct way to describe K in declarative form

Page 11: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 11

IM

¢  We consider the case of production rules

¢  The IM decides

l  What rules apply? In which order?

¢  Use of FB with its enrichment

¢  The modes of reasoning

l  How the IM uses the K made available to it l  Two modes of reasoning

•  Forward Chaining : get all deductible facts until reaching the solution (no focus on purpose)

•  Backward chaining: replace the hypothesis with a set of sub-goals (risk of looping)

Page 12: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 12

IM ¢  Introduction

l  Set of candidate rules l  Choice of the rule to trigger

¢  Example l  RB

•  R1 IF animal has feathers THEN animal is a bird

•  R2 IF animal flies AND animal lays eggs

THEN animal is a bird

•  R3 IF animal is a bird AND animal remarkable flight

THEN animal is an albatros l  BF

•  F1 animal flies •  F2 animal has feathers •  F3 animal remarkable flight

Page 13: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 13

IM (Forward chaining)

•  R1 IF animal has feathers THEN animal is a bird

•  R2 IF animal flies AND animal lays eggs

THEN animal is a bird

•  R3 IF animal is a bird AND animal remarkable flight

THEN animal is an albatros

¢  Proposition: animal is an albatros

l  Forward chaining

animal flies animal has feathers animal remarkable flight

animal flies animal has feathers animal remarkable flight animal is a bird

animal flies animal has feathers animal remarkable flight animal is a bird animal is analbatros

R1 R3

Page 14: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 14

IM (Forward chaining)

¢  Forward-chaining consists in starting from facts describing a situation and using the rule base to try to deduce as many new facts as it is possible (saturation of the fact base). This is a direct use of the modus ponens inference rule

¢  Example (Forward Chaining) l  Facts:

•  b, c, m, n l  Rules:

•  R1 IF a Then d And f •  R2 IF b And d Then g And h •  R3 IF f And e Then l And o

l  New fact1 (provided by user): a Deduced facts: d, f, g, h l  New fact2 (provided by user): e Deduced facts: none l  New fact3 (provided by user): a And e Deduced facts: d, f, g, h, l, o

Page 15: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 15

IM (Backward-chaining )

•  R1 IF animal has feathers THEN animal is a bird

•  R2 IF animal flies AND animal lays eggs

THEN animal is a bird

•  R3 IF animal is a bird AND animal remarkable flight

THEN animal is an albatros

¢  Proposition: animal is an albatros

l  Backward chaining

Animal is an albatros

animal remarkable flight

animal is a bird

animal has feathers

animal flies animal lays eggs

R1 R3 R2

Page 16: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 16

IM (Backward-chaining ) ¢  Backward-chaining consists in setting an hypothetical fact (in Prolog terms we speak

of a goal) and using the rule base and the inference engine to go backward and to try to retrieve the facts in the fact base and the chain of rules that enable to deduce the hypothetical fact

¢  Example (Backward Chaining) l  Facts:

•  b, c, m, n l  Rules:

•  R1 IF a Then d And f •  R2 IF b And d Then g And h •  R3 IF f And e Then l And o

¢  Hypothesis (submitted by user): f Proof: No Explanation: R1 cannot be triggered Advice: Try to verify fact a

¢  New fact (provided by user): a Proof: f true (backward chaining)

Explanation: d And f true because rule R1 and fact a Other deduced facts: g, h

¢  In practice, most systems use both Forward and Backward Chainings

Page 17: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 17

IM

Determine pertinent rules using matching

Select one rule

Execute the selected rule

General Cycle

¢  Filtering operation and rule selection strategy

l  Comparison of each of the rules of the KB with the set of facts à filtering operation (pattern matching)

l  No ideal solution for choosing a single rule to trigger

•  The 1st •  The simplest •  etc.

Page 18: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 18

Deduction systems ¢  Deduction system to identify animals (zoologist expert)

l  Observing an animal l  Series of Questions l  Identify the observed animal

¢  Example of interaction

l  ES: Does the animal have hairy bodies? l  User: yes

l  ES: Does the animal have the tips of the paws with claws? l  User: yes

l  ES: Does the animal have eyes directed forward? l  User: yes

l  ES: Is the shape of the animal's teeth sharp? l  User: yes

l  ES: Is the color of the animal brown? l  User: yes

l  ES: Does the animal's dress have black stripes? l  User: yes

l  ES: According to my K, the animal is a tiger

Page 19: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 19

Deduction systems R1 R2 R3 R4 R5 R6 R7 R8 R9

IF animal body is worth "hairs" THEN animal is a mammal

R10 R11 R12 R13 R14 R15 R16

IF animal is an "ungulate" AND nature of legs is "long" AND nature of the neck is "long" AND color is "brown" AND dress is "Black rayes" THEN animal is a giraffe

IF food_young animal is "milk" THEN animal is a mammal

IF animal body is "feathers" THEN animal is a bird

IF animal is an "ungulate" AND color is "white" AND dress is "black stripes" THEN animal is a zebra

IF locomotion animal is ”flies" AND animal reproduction is "eggs" THEN animal is a bird

IF animal is a "mammal" AND animal food is "meat" THEN animal is a carnivore

IF animal is a "bird" AND animal locomotion is "does not fly" THEN animal is a non-flying bird

IF animal is a "mammal" AND eye direction is "forward" AND teeth shape is "pointed" And ends of the legs is "claws" THEN animal is a carnivore

IF animal is a "bird" AND animal locomotion is "swim" THEN animal is a non-flying bird

IF animal is a "mammal" And extremities of the legs is "nails" THEN animal is an ungulate

IF animal is a "non-flying bird" AND nature of legs is "long" AND nature of the neck is "long" AND color is "black and white" THEN animal is an ostrich

IF animal is a "carnivore" AND color is "brown" AND dress is "Black Tasks" THEN animal is a hedge IF animal is a "non-flying bird"

AND nature of the legs is "palmate" AND color is "black and white" THEN animal is a penguin

IF animal is a "carnivore" AND color is "brown" AND dress is "black stripes" THEN animal is a tiger IF animal is a "bird"

AND nature of the flight is "remarkable" THEN animal is an albatross bird

Page 20: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 20

Systèmes de déduction - Exemple

¢  IM forward chaining

l  Observed Animal : abcdef

l  Working memory •  Covered body is "hairs" •  End of the legs is "nails" •  Nature of neck is "long" •  Color is "brown" •  Dress "black”

l  abcdef is a giraffe (R1, R7, R10)

Page 21: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 21

Deduction system - Example

¢  IE backward chaining

l  Observed Animal: abcdef

l  Hypothesis to be verified: abcdef is a cheetah

l  Working memory …

Page 22: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 22

Explanation

B

B1 B2 B3

How(B) ==> B1 ∧ B2 ∧ B3

Why(B2) ==> B

Page 23: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 23

ES Examples

¢ The agricultural harvest

¢ Help with diagnosis

¢ Decision support in the identification of micro-organisms responsible for infections: MYCIN

¢ Medical Decision Support: SPHINX l Application to diagnose diseases frequently

caught in shrimps

Page 24: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 24

ES - Management

¢  Aim of a Management ES: Assist business managers in making decisions to solve complex problems with the competence of a management expert

¢  Need M-ES for:

l  HR management (recruitment, assignment, transfer, etc.) l  Financial management l  Marketing

¢  Management of Portfolios

l  Assist a bank's advising clients with respect to investments ¢  Orient the loan decisions based on a complete diagnosis of the

company's strengths and weaknesses

Page 25: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 25

Loan Expert Systems

Page 26: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 26

Medical ES ¢  The medical procedure is divided into four stages:

1.  Examination of the patient 2.  Elaboration of the diagnosis 3.  Therapeutic prescription 4.  Monitoring the evolution

¢  ESs concern steps 2, 3 & 4

¢  Example: A patient consults a physician for some illness l  The physician asks the patient for data

•  symptoms and patient’s characteristics à Facts l  The physician uses his/her medical knowledge (rules about symptoms and illnesses) to deduce new

facts (forward-chaining) l  He can also set hypothesis (backward chaining). Based on an hypothesis (‘patient has the flu’),

the physician may ask questions to the patient to verify facts that have not been identified yet, or the physician may ask the patient to undergo tests to verify some facts (Symptoms). With all these facts the physician can deduce the patient’s illness (forward-chaining) with a certain degree of certainty

l  When the physician has identified the patient’s illness, s/he uses his/her knowledge of cures (rules about illnesses and medication) to prescribe some medicine to the patient (forward-chaining)

Page 27: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 27

¢  DESIGN ADVISOR l  Gives advice to designers of processor chips

¢  DENDRAL l  Used to identify the structure of chemical compounds.

¢  PROSPECTOR l  Used by geologists to identify sites for drilling or mining

¢  MYCIN l  Medical system for diagnosing blood disorders. First used in 1979

Known ES examples

Page 28: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 28

¢  Limited domain ¢ Systems are not always up to date, and don’t

learn ¢ No “common sense” ¢ Experts needed to setup and maintain system ¢ Who is responsible if the advice is wrong?

Problems with Expert Systems

Page 29: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 29

Demo – PID ES

Page 30: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 30

Demo – PID ES

Page 31: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 31

Demo – PID ES

Page 32: Expert Systems - École Mohammadia d'ingénieurs...• R1 IF animal has feathers THEN animal is a bird • R2 IF animal flies AND animal lays eggs THEN animal is a bird • R3 IF animal

Artificial Intelligence Copyright Karim Bouzoubaa 32

http://www.easydiagnosis.com/login/modules.html http://www.exsys.com/demomain.html

Examples of ES