expert systemsnov 04, 2019  · popular expert systems • pxdes –is a expert system that uses an...

32
Budditha Hettige Department of Computer Engineering Faculty of Computing General Sir John Kotelawala Defence University SOURCE : Building Expert Systems in Prolog, Dennis Merritt Expert Systems

Upload: others

Post on 10-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Budditha Hettige

Department of Computer Engineering

Faculty of Computing

General Sir John Kotelawala Defence University

SOURCE : Building Expert Systems in Prolog, Dennis Merritt

Expert Systems

Page 2: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Overview

• What is an Expert System?

• What are the Expert system features?

• Steps to Expert System development

– Knowledgebase

– User Interface

– Shell

• Prolog Java Interface (JPL)

• Prolog Web Interface

• Examples

27/11/2015 Budditha Hettige ([email protected])

Page 3: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

7/11/2015 Budditha Hettige ([email protected]) 3

Page 4: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Expert System

• Computer applications which embody some non-

algorithmic expertise for solving certain types of

problems

7/11/2015 Budditha Hettige ([email protected]) 4

{Dennis Merritt}

Page 5: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Advantages

• Easy to develop and modify

• The use of satisficing (accepting satisfactory solution rather than the optimal one)

• The use of heuristics

• Development by knowledge engineers and users

• Goal driven reasoning or backward chaining

• Coping with uncertainty

• Data driven reasoning or forward chaining

• Data representation

• User interface

• Explanations

7/11/2015 Budditha Hettige ([email protected]) 5

Page 6: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Limitations of Expert Systems

• Limited to relatively narrow problems

• Cannot readily deal with “mixed” knowledge

• Possibility of error

• Cannot refine own knowledge base

• Difficult to maintain

• May have high development costs

• Raise legal and ethical concerns

7/11/2015 Budditha Hettige ([email protected]) 6

Page 7: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Applications of Expert Systems• Credit granting

• Information management and retrieval

• AI and expert systems embedded in products

• Plant layout

• Hospitals and medical facilities

• Help desks and assistance

• Employee performance evaluation

• Loan analysis

• Virus detection

• Repair and maintenance

• Shipping

• Marketing

• Warehouse optimization

Page 8: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

7/11/2015 Budditha Hettige ([email protected]) 8

Page 9: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Participants in Expert Systems

Development and Use

• Domain expert– The individual or group whose expertise and knowledge is

captured for use in an expert system

• Knowledge user– The individual or group who uses and benefits from the

expert system

• Knowledge engineer– Someone trained or experienced in the design,

development, implementation, and maintenance of an expert system

7/11/2015 Budditha Hettige ([email protected]) 9

Page 10: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Evolution of Expert Systems Software

• Expert system shell

– Collection of software packages & tools to design,

develop, implement, and maintain expert systems

7/11/2015 Budditha Hettige ([email protected]) 10

Page 11: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Expert Systems Development

Alternatives

7/11/2015 Budditha Hettige ([email protected]) 11

Page 12: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Popular Expert Systems

• PXDES

– Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

– Uses X-rays to look at shadows on the lungs

• MyCIN

– MYCIN was an early backward chaining expert system

– Operated using fairly simple inference engine, and a knowledge base of ~600 rules

7/11/2015 Budditha Hettige ([email protected]) 12

Page 13: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Steps to

Expert System Development

• Identify the problem

• Build up Knowledge base

– Fats

– Rules

– Expirations

• Build up Inference Engine

– Way to sole problem

• Design a user Interface

7/11/2015 Budditha Hettige ([email protected]) 13

Page 14: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Identify the problem

• Input

– What are the Questions?

– What is the order of the Questions?

• Output

– What is the final result(s)?

• Facts

– What are the fats requires to collect the answers?

• Explanations

– In case, what are the explanations?

7/11/2015 Budditha Hettige ([email protected]) 14

Page 15: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Build up Knowledgebase

• What are the facts?

• What are the rules?

• How they represents?

• Example

family(duck):-

order(waterfowl), feed(on_water_surface), flight(agile).

bird(mallard):- family(duck), voice(quack), head(green).

bird(mallard):- family(duck), voice(quack), color(mottled_brown).

bird(pintail):- family(duck), voice(short_whistle).

7/11/2015 Budditha Hettige ([email protected]) 15

Page 16: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Build up Inference Engine

• Prolog has a built-in backward chaining inference engine that can be used to partially implement some expert systems

• The rules for expert systems are usually written in the form:

– bird(pintail):- family(duck), voice(short_whistle).

7/11/2015 Budditha Hettige ([email protected]) 16

Page 17: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

User Interface

• The system can be dramatically improved by

providing a user interface

• Identify Attribute and values for the each case

7/11/2015 Budditha Hettige ([email protected]) 17

Page 18: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Ask Questions

7/11/2015 Budditha Hettige ([email protected]) 18

Page 19: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Menu for a user

• Example:

7/11/2015 Budditha Hettige ([email protected]) 19

Page 20: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Remembering the answer

• Example:

7/11/2015 Budditha Hettige ([email protected]) 20

Page 21: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Expert System Shell

• Architecture of the Native shell.

7/11/2015 Budditha Hettige ([email protected]) 21

Page 22: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

The Shell

• The shell will seek to solve a generic predicate called

top_goal.

top_goal(X) :- bird(X).

• The shell has a predicate called solve, which does some

housekeeping and then solves for the top_goal.

• Example

7/11/2015 Budditha Hettige ([email protected]) 22

Page 23: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Explanation

• Expert systems have ability to explain theirbehavior.

• This means the user can ask the system for justification of conclusions or questions at any point in a consultation with an expert system

• Types of Explanation

– A rule trace, which reports on the progress of a consultation;

– Explanation of how the system reached a given conclusion;

– Explanation of why the system is asking a question;

– Explanation of why not a given conclusion.

7/11/2015 Budditha Hettige ([email protected]) 23

Page 24: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Explanation (Questions)

The why questions occur at the bottom of an inference

chain, and the how questions occur at the top

7/11/2015 Budditha Hettige ([email protected]) 24

Page 25: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Java Prolog Interface

• SET PATH for the swipl.exe

– C:\Program Files (x86)\swipl\bin

• Add jpl.jar to your project

• Create suitable prolog source file

• Add prolog source file into your java project folder

• Import jpl and complete your development

7/11/2015 Budditha Hettige ([email protected]) 25

Page 26: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Java Codes for Prolog connection

• Import JPL libraryimport org.jpl7.JPL;

import org.jpl7.Query;

import org.jpl7.Term;

• Collect JPL information

7/11/2015 Budditha Hettige ([email protected]) 26

Page 27: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

JPL Code

• Consult prolog sourceString t1 = "consult('family.pl')";System.out.println(t1 + " " + (Query.hasSolution(t1) ? "succ" : "failed"));

• Run Prolog predicate String t2 = "child_of(joe, ralf)";

System.out.println(t2 + " is " + (Query.hasSolution(t2) ? "pro" : "not"));

• Get one solutionString t4 = "descendent_of(X, ralf)";

System.out.println("first solution of " + t4 + ": X = " +

Query.oneSolution(t4).get("X"));

7/11/2015 Budditha Hettige ([email protected]) 27

Page 28: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

JPL Code (2)

String t4 = "descendent_of(X, ralf)";

Map<String,Term>[] ss4 =

Query.allSolutions(t4);

System.out.println("all solutions of " + t4);

for (int i = 0; i < ss4.length; i++)

{

System.out.println("X = " + ss4[i].get("X"));

}

7/11/2015 Budditha Hettige ([email protected]) 28

Page 29: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

JPL Code (3)

String t5 = "descendent_of(X,Y)";

Query q5 = new Query(t5);

System.out.println("each solution of " + t5);

while (q5.hasMoreSolutions())

{

Map<String, Term> s5 = q5.nextSolution();

System.out.println("X = " + s5.get("X") + ",

Y = " + s5.get("Y"));

}

7/11/2015 Budditha Hettige ([email protected]) 29

Page 30: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Example (relation.pl)

male(somapala).

male(gunapala).

male(rathnapala).

female(seela).

female(susila).

female(neetha).

parent(seela,kamal).

parent(seela,nayana).

parent(seela,saman).

parent(somapala,kamal).

parent(somapala,nayana).

parent(somapala,saman).

parent(kamal,sanjaya).

parent(ruvani,sanjaya).

parent(saman,susi).

parent(saman,yasith).

parent(saman,oshan).

parent(kumari,susi).

parent(kumari,yasith).

parent(kumari,oshan).

print:-write('how are you').

print(X):- write('Anwer is '),write(X),nl.

print(X,Y):- write('Anwer is '),write(X), write(Y),nl.

mother(X,Y):-female(X),parent(X,Y).

father(X,Y):-male(X),parent(X,Y).

son(X,Y):- male(X),parent(Y,X).

whois(X, Y) :- mother(X,Y), write(X), write(' is mother of'), write(Y).

whois(X, Y) :- father(X,Y), write(X), write(' is father of'), write(Y).

whois(X, Y) :-

son(X,Y), write(X), write(' is son of'), write(Y).

7/11/2015 Budditha Hettige ([email protected]) 30

Page 31: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Example:

7/11/2015 Budditha Hettige ([email protected]) 31

Page 32: Expert SystemsNov 04, 2019  · Popular Expert Systems • PXDES –Is a expert system that uses an inference engine to determine the type and degree of pneumoconiosis, or lung cancer

Activity

• Create an expert system to select a suitable A/L

stream

– What should be the output

– Questions

– Order of the questions

– Input methods

7/11/2015 Budditha Hettige ([email protected]) 32