alford academy business education and computing1 1 advanced higher computing based on heriot-watt...

25
Alford Academy Business Education and Computing 1 Alford Academy Business Education and Computing 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Upload: ada-owens

Post on 18-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 1Alford Academy Business Education and Computing 1

Advanced Higher Computing

Based on Heriot-Watt University Scholar Materials

Rule Based Systems

Page 2: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 2Alford Academy Business Education and Computing 2

Lesson Objectives

Expert SystemsIf .. Then RulesInferencing in Rule Based SystemsCertainty Factors

Page 3: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 3Alford Academy Business Education and Computing 3

Expert Systems

An expert system has 3 components:

Often built using an expert system shell

Expert system shell has no

knowledge base

Page 4: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 4

Stages of Creating an Expert System

1. knowledge acquisition

2. knowledge representation

3. system validation

Page 5: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 5

Knowledge acquisition

Domain expert:• personal experience of problems to be solved• personal expertise in how to solve the problems• personal knowledge of the reasons for selecting certain methods.

Knowledge engineer:• no specialist knowledge of the domain• need to learn from the domain experts, prior to the start of the project and during the acquisition of knowledge.

Page 6: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 6

Difficulties

Sort the 9 difficulties on pages 92 and

93 of the Scholar notes in order of negative

impact on knowledge acquisition:

Let 1 = least impact and 9 = most impact

Page 7: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 7

Knowledge Representation

1. Use an expert system shell

2. Use a declarative language (Prolog)

3. Use a procedural language – need to program all parts of the system

Page 8: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 8

System Validation

System tests that compare the advice of the expert system with that of

the domain expert. Possible errors include:

1. Incomplete knowledge or incorrect representation

2. Misunderstanding of knowledge engineer with information provided by domain expert

3. Knowledge not being processed correctly

Page 9: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 9

If .. Then Rules

Consider the following knowledge base

Can use forward or backward rules

Page 10: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 10

Forward Rules

Of the form IF condition(s) THEN conclusion

If colour = bronze AND

size (mm) = 18 AND

shape = round AND

symbol = fish

Then value = 1H.

Page 11: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 11

Backward Rules

Of the form conclusion IF condition(s)

value = 1H If

colour = bronze AND

size (mm) = 18 AND

shape = round AND

symbol = fish.

Page 12: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 12

Visual Comparison

Page 13: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 13

Practical Activity

Do Task 5.4.3 on page 98 of Scholar notes.

Page 14: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 14

Justification and Explanation

it helps the enquirer to understand the subject better;

it means that the enquirer can learn how the expert thinks;

it gives the enquirer more confidence in the advice given.

Page 15: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 15

Investigation

Do Task Exploring Justification Features on

page 99 of Scholar notes.

Page 16: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 16

How an Expert System reaches its conclusionEssentially, the inference engine uses a search algorithm to search through therules in a similar fashion to the evaluation of a query in Prolog (see Topic 4).The rules can be represented as a decision tree:

The tree can be searched either breadth-first or depth-first.

The inference engine can also be classified as either forward chaining or backwardchaining.

Page 17: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 17

Practical Activity

Read notes on page 100 – do activityExamining the behaviour of an inference engine

Page 18: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 18

Advantages and Disadvantages of Forward Chaining

Page 19: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 19

Advantages and Disadvantages of Backward Chaining

Many Expert Systems use a combination of backward and forward chaining

Page 20: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 20

Rules, facts and working memoryBackward chaining systems tend to use depth-first search with backtracking, in a similar way to Prolog. This is completelypredictable in operation, following a clear strategy to reach a conclusion.

For example, suppose a medical expert systems had the following facts in working memory:

Body temperature is 39.5ÆCPatient’s skin colour is redPatient has pains in stomach and legsAge of patient is 63Gender of patient is femaleCondition has occurred before

One of the rules in the system is:IF body temperature 38AND patient’s skin colour is red THEN patient has fever

This rule could be fired, and would add the fact:

Patient has fever

to the working memory.As a result, another rule:IF patient has feverAND patient has pains in stomach and legs THEN patient may have influenza.

could be fired, leading to a diagnosis / conclusion.

Page 21: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 21

Conflict resolution

At any time, there may be hundreds of different rules that could be fired by the known facts. The inference engine must decide which of the possible rules should be fired next

The set of possible rules which could be fired at any particular time is known as the conflict set

The inference engine must use some form of conflict resolution to decide which rule from the conflict set to fire next

Many different conflict resolution strategies can be used, either separately or in combination

Page 22: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 22

Conflict resolution strategies

Page 23: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 23

Certainty factors

a consultation with a doctor may lead to a less clear-cut diagnosis. The doctor may conclude that your headache is probably just a hangover, but it might be the start of flu, and there is a very slim chance that it could be a brain tumour or some other serious disease.

domains can contain inexact conclusions like this, and expert systems must be able to deal with this kind of knowledge. This involves using certainty factors

The number is called a certainty factor. It is added to the end of a fact or rule using the abbreviation CF.

Page 24: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 24

Examples of using certainty factors

Practical Activity – Do weather forecast expert system task on page 104

Page 25: Alford Academy Business Education and Computing1 1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Rule Based Systems

Alford Academy Business Education and Computing 25

Calculating certainty factors - complex

Example 1

IF the sky was red this morning (CF 60)AND it rained yesterday (CF 75)THEN it will rain today (CF 50).

CF = MIN(60%,75%) x 50%

= 30%

CF = 30

Example 2

IF the sky is blue (CF 90)AND people around are speaking French (CF 40)AND there are lots of Renault cars (CF 60)THEN you are in France (CF 80)

CF = MIN(90%,40%,60%) x 80%

= 32%

CF = 32