Presentation is loading. Please wait.

Presentation is loading. Please wait.

Expert Systems. An expert system is “an intelligent computer program that uses knowledge and inference procedures to solve problems that are difficult.

Similar presentations


Presentation on theme: "Expert Systems. An expert system is “an intelligent computer program that uses knowledge and inference procedures to solve problems that are difficult."— Presentation transcript:

1 Expert Systems

2 An expert system is “an intelligent computer program that uses knowledge and inference procedures to solve problems that are difficult enough to require significant human expertise for their solutions.” – Edward Feigenbaum INTERNIST II is an expert system which has been tested against experienced physicians in the field of internal medicine. It arrived at the correct diagnosis, first time, 83% of the time whereas experienced human physicians managed 82%. An expert system solves such problems as good as a human expert or even better. An expert system can explain its behavior by answering questions such as: Why are you asking this question? Why didn’t you try X? How did you reach this conclusion?

3 WHAT DOES AN EXPERT SYSTEM LOOK LIKE? The following is a sample interaction between a physician and an expert system called MYCIN. [MYCIN] What is the patient's name? [Doc] John Doe Male or female? Male. Age? He is 55. Have you obtained positive cultures indicating general type? Yes. What type of infection is it? Primary Bacteremia. When did symptoms first appear? May 5, 2002.

4 USER: HOW ? TEIRESIAS: (i.e. HOW was it established that the aerobicity of ORGANISM-1 is facultative?) The following were used : [3.1] RULE 27 indicated there is strongly suggestive evidence (.8) that the aerobicity of ORGANISM- 1 is facultative [3.2] RULE 27 indicated there is weakly suggestive evidence (.2) that the aerobicity of ORGANISM-1 is anaerobic Since this gave a cumulative CF of (.8) for facultative, and (.2) for anaerobic, it has been established that the aerobicity of ORGANISM-1 is facultative. USER: WHY DIDN'T YOU CONSIDER STREPTOCOCCUS AS A POSSIBILITY FOR ORGANISM-1? TEIRESIAS: The following rule could have been used to determine that the identity of ORGANISM-1 was streptococcus: RULE 33. But clause 2 ('the morphology of the organism is coccus') was already known to be false for ORGANISM-1, so the rule was never tried.

5 Production Rules If Condition(s) Then Action An Example: IFthe stain of the organism is gramneg ANDthe morphology of the organism is rod ANDthe aerobicity of the organism is aerobic THENthere is strongly suggestive evidence (0.8) that the class of the organism is enterobacteriaceae In Prolog +Condition -> +Action (yes(S) -> true ; (no(S) -> fail ; ask(S))). If -> Then ; Else is actually a term of the form ; (->(If, Then), Else). or(->(yes(S),true), or(->(no(S),fail),ask(S))

6 Inference Engine Knowledge Base Working Memory Explanation Facility User User Interface Domain Expert(S) Knowledge Engineer Knowledge Formalized Knowledeg

7 Simple expert systems in Prolog 1. Animal identification

8 Does the animal have the following attribute: gives_milk? yes. Does the animal have the following attribute: eats_meat? no. Does the animal have the following attribute: has_pointed_teeth? yes. Does the animal have the following attribute: has_claws? yes. Does the animal have the following attribute: has_forward_eyes? yes. Does the animal have the following attribute: has_tawny_color? yes. Does the animal have the following attribute: has_dark_spots? no. Does the animal have the following attribute: has_black_stripes? yes. I guess that the animal is: tiger Yes ?- go. Does the animal have the following attribute: has_hair? no.

9 go :- hypothesize(Animal), write('I guess that the animal is: '), write(Animal), nl, undo. /* hypotheses to be tested */ hypothesize(cheetah) :- cheetah, !. hypothesize(tiger) :- tiger, !. hypothesize(giraffe) :- giraffe, !. hypothesize(zebra) :- zebra, !. hypothesize(ostrich) :- ostrich, !. hypothesize(penguin) :- penguin, !. hypothesize(albatross) :- albatross, !. hypothesize(unknown). /* no diagnosis */

10 /* animal identification rules */ cheetah :- mammal, carnivore, verify(has_tawny_color), verify(has_dark_spots). tiger :- mammal, carnivore, verify(has_tawny_color), verify(has_black_stripes). giraffe :- ungulate, verify(has_long_neck), verify(has_long_legs). zebra :- ungulate, verify(has_black_stripes). ostrich :- bird, verify(does_not_fly), verify(has_long_neck).

11 penguin :- bird, verify(does_not_fly), verify(swims), verify(is_black_and_white). albatross :- bird, verify(appears_in_story_Ancient_Mariner), verify(flys_well). /* classification rules */ mammal :- verify(has_hair), !. mammal :- verify(gives_milk). bird :- verify(has_feathers), !. bird :- verify(flys), verify(lays_eggs). carnivore :- verify(eats_meat), !.

12 carnivore :- verify(has_pointed_teeth), verify(has_claws), verify(has_forward_eyes). ungulate :- mammal, verify(has_hooves), !. ungulate :- mammal, verify(chews_cud). /* how to ask questions */ ask(Question) :- write('Does the animal have the following attribute: '), write(Question), write('? '), read(Response), nl, ( (Response == yes ; Response == y) -> assert(yes(Question)) ; assert(no(Question)), fail).

13 :- dynamic yes/1,no/1. /* How to verify something */ verify(S) :- (yes(S) -> true ; (no(S) -> fail ; ask(S))). /* undo all yes/no assertions */ undo :- retract(yes(_)),fail. undo :- retract(no(_)),fail. undo.

14 2. Farm management

15 ?- go. Is the stocking of the jack pine stand currently at least minimum ? If you are unsure of how to determine stocking, see page 4 in the Managers Handbook for Jack Pine |: yes. Is the average diameter of the trees less than 5 inches ?no. Is the age of the stand mature or immature ?i. Please respond with : [mature, immature] Is the age of the stand mature or immature ?immature. Is the site index greater than 60 ?yes. Do you want to manage the timber for large or small products ?large. Is the basal area per acre at least 120 square feet ?jjj. Please respond with : [yes, no] Is the basal area per acre at least 120 square feet ?yes. Is there a high risk of loss or injury ?no.

16 Based upon your responses, the following is recommended : It is important to thin the area You should wait before doing anything else to this stand. To see the complete set of derived facts, type "display_kb." Yes ?- display_kb. stocking good is yes avg < 5 is no age is immature site index > 60 is yes product size is large 120+ basal area is yes advice is It is important to thin the area high risk is no advice is You should wait before doing anything else to this stand. Yes ?-

17 /* ESFM.PL*/ go :- clear_kb, give_advice. give_advice :- recommendation(X), fail. give_advice :- write_advice. /* The rules */ fact(branch8,yes) :- fact('stocking good',yes), fact('avg < 5',yes), fact('2000+ per acre',yes), recommend('The stand of jack pine must be weeded and cleaned.').

18 fact(branch8,yes) :- fact('stocking good',yes), fact('avg < 5',yes), fact('2000+ per acre',no). fact(branch9,no) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,mature), assertz(fact(branch11,yes)). fact(branch11,yes) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,mature), assertz(fact(branch9,no)).

19 fact(branch9,yes) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,immature), fact('site index > 60',yes), fact('product size',large), fact('120+ basal area',yes), recommend('It is important to thin the area'). fact(branch9,yes) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,immature), fact('site index > 60',yes), fact('product size',large), fact('120+ basal area',no).

20 fact(branch9,yes) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,immature), fact('site index > 60',yes), fact('product size',large). fact(branch9,yes) :- fact('stocking good',yes), fact('avg < 5',no), fact(age,immature), fact('site index > 60',yes). fact(branch11,yes) :- fact('stocking good',no), fact('other resources',no).

21 fact(branch9,yes) :- fact(branch8,yes), fact('severe competition',yes), recommend('Competing trees should be eliminated.'). fact(branch9,yes) :- fact(branch8,yes), fact('severe competition',no). fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',yes), fact('10/acres adequate',yes), fact('burning planned',no), add_fact(silvaculture,clearcut), recommend('The best silvaculture method to use is clearcut.').

22 fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',yes), fact('10/acres adequate',no), add_fact(silvaculture,clearcut), recommend('The best silvaculture method to use is clearcut.'). fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',no), fact('two harvests wanted',yes), fact('two harvests possible',yes), add_fact(silvaculture,shelterwood), recommend('The best silvaculture method to use is the shlterwood method.').

23 fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',no), fact('two harvests wanted',yes), fact('two harvests possible',no), add_fact(silvaculture,clearcut), recommend('The best silvaculture method to use is clearcut.'). fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',no), fact('two harvests wanted',no), add_fact(silvaculture,clearcut), recommend('The best silvaculture method to use is clearcut.').

24 fact(branch17,yes) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',no), add_fact(silvaculture,clearcut), recommend('The best silvaculture method to use is clearcut.'). fact(branch18,yes) :- fact(branch17,yes), fact('adequate seedbed',yes). fact(branch18,yes) :- fact(branch17,yes), fact('adequate seedbed',no), recommend('The site should be prepared before planting.'). fact(X,Y) :- kb(X,Y),!.

25 fact(X,Y) :- not(kb(X,Anything)), question(X,Answer), assertz(kb(X,Answer)), Y = Answer. recommendation(maintain) :- fact('stocking good',no), fact('other resources',yes), recommend('You should maintain the stand in its present condition'). recommendation(control) :- fact(branch9,yes), fact('high risk',yes), recommend('The current area should be controlled, if at all feasible.').

26 recommendation(wait) :- fact(branch9,yes), fact('high risk',no), recommend( 'You should wait before doing anything else to this stand.' ). recommendation('use seed tree') :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',yes), fact('desirable seed',yes), fact('serotinous cones',yes), fact('10/acres adequate',yes), fact('burning planned',yes), recommend('You should use seed trees to seed the area.').

27 recommendation(convert) :- fact(branch11,yes), fact('pine desired',yes), fact('pine suited',no), recommend( 'You should convert the area to some more desirable kind of tree.' ). recommendation(convert) :- fact(branch11,yes), fact('pine desired',no), recommend( 'You should convert the area to some more desirable kind of tree.' ). recommendation('natural seeding') :- fact(branch18,yes), fact(silvaculture,shelterwood), recommend('The natural seeding technique should be used.'). recommendation(plant) :- fact(branch18,yes), fact(silvaculture,clearcut), fact('improved stock',yes), recommend( 'Since there is better stock available, you can plant using that stock.' ).

28 recommendation('scatter cones') :- fact(branch18,yes), fact(silvaculture,clearcut), fact('improved stock',no), fact('good cone supply',yes), recommend('You should scatter the serotinous cones over the area.'). recommendation('direct seed') :- fact(branch18,yes), fact(silvaculture,clearcut), fact('improved stock',no), fact('good cone supply',no), recommend('You should directly seed the area.'). /* Add fact to KB if not already there. */ add_fact(X,Y) :- kb(X,Y),!.

29 add_fact(X,Y) :- assertz(kb(X,Y)). recommend(X) :- add_fact(advice,X). /* Questions to ask the user */ question('stocking good',Ans) :- write('Is the stocking of the jack pine stand currently'),nl, write('at least minimum ? '),nl,nl, write('If you are unsure of how to determine stocking,'),nl, write('see page 4 in the Managers Handbook for Jack Pine'), nl, ask('',Ans,[ yes, no ]).

30 question('avg < 5',Ans) :- ask('Is the average diameter of the trees less than 5 inches ?', Ans,[yes,no]). question('2000+ per acre',Ans) :- ask('Are there 2000 or more trees per acre ?',Ans,[yes,no]). question(age,Ans) :- ask('Is the age of the stand mature or immature ?', Ans,[mature,immature]). question('site index > 60',Ans) :- ask('Is the site index greater than 60 ?',Ans,[yes,no]). question('product size',Ans) :- ask('Do you want to manage the timber for large or small products ?', Ans,[large,small]).

31 question('120+ basal area',Ans) :- ask('Is the basal area per acre at least 120 square feet ?', Ans,[yes,no]). question('other resources',Ans) :- ask('Do you want to maintain this condition to support other resources?',Ans,[yes,no]). question('severe competition',Ans) :- ask('Is there severe overstory competition ?',Ans,[yes,no]). question('high risk',Ans) :- ask('Is there a high risk of loss or injury ?',Ans,[yes,no]). question('pine desired',Ans) :- ask('Do you want to keep jack pine in this area ?',Ans,[yes,no]). question('pine suited',Ans) :- ask('Is jack pine well suited to this site ?',Ans,[yes,no]).

32 question('desirable seed',Ans) :- ask('Is there a desirable jack pine seed source on the area ?', Ans,[yes,no]). question('serotinous cones',Ans) :- ask('Do the trees on the site have serotinous cones ?',Ans,[yes,no]). question('10/acres adequate',Ans) :- ask('Are 10 trees per acre adequate to seed the area ?',Ans,[yes,no]). question('burning planned',Ans) :- ask('Has a prescribed burning been planned ?',Ans,[yes,no]). question('two harvests wanted',Ans) :- ask('Do you want two commercial harvests on this area ?',Ans,[yes,no]). question('two harvests possible',Ans) :- ask('Is it possible to get two harvests from this area ?',Ans,[yes,no]).

33 question('adequate seedbed',Ans) :- ask('Is there an adequate seedbed for planting ?',Ans,[yes,no]). question('improved stock',Ans) :- ask('Is there an improved planting stock available ?',Ans,[yes,no]). question('good cone supply',Ans) :- ask('Is there a good supply of serotinous cones in the area ?', Ans,[yes,no]). /* Utility Routines - to be useful, we should add some routines to allow the user to ask 'How' and 'Why' */ display_kb :- kb(X,Y), write(X),write(' is '),write(Y), nl, fail. display_kb.

34 write_advice :- nl,nl,write( 'Based upon your responses, the following is recommended:' ),nl, nl, show_advice. show_advice :- kb(advice,X), write(X),nl,fail. show_advice :- nl,write('To see the complete set of derived facts, '), write('type "display_kb."'), nl. clear_kb:- retractall(kb(_,_)). ask(Ques,Ans,LegalResponses) :- nl, write(Ques),read(Ans), member(Ans,LegalResponses),!. ask(Ques,Ans,LegalResponses) :- nl, nl,write('Please respond with : '), write(LegalResponses), nl, nl, ask(Ques,Ans,LegalResponses).


Download ppt "Expert Systems. An expert system is “an intelligent computer program that uses knowledge and inference procedures to solve problems that are difficult."

Similar presentations


Ads by Google