Computing Intermodeller Notes for Artificial Intelligence

advertisement

Computing

Intermodeller Notes for

Artificial Intelligence

Higher

9028

.

Autumn 2001

HIGHER STILL

Computing

InterModeller Notes for

Artificial Intelligence

Higher

Support Materials

Acknowledgements

The Higher Still Development Programme would like to thank Parallel Logic

Programming Ltd for permission to reproduce the InterModeller screen shots.

Every attempt has been made to gain permission to use extracts from the appropriate copyright owners. The Higher Still Development Programme apologises for any omission which, if notified, it will be pleased to rectify at the earliest opportunity.

This publication may be reproduced in whole or in part for educational purposes provided that no profit is derived from the reproduction and that, if reproduced in part, the source is acknowledged.

First published 2001

Learning + Teaching Scotland

Northern College

Gardyne Road

Broughty Ferry

Dundee

DD5 INY

Tel. 01382 443 600

CONTENTS

SECTION 1: TEACHER NOTES

SECTION 2: INTRODUCTION TO INTERMODELLER

SECTION 3: CREATING EXPERT SYSTEMS USING INTERMODELLER

3.1 Decision trees

3.2 Tables

3.3 Classification trees

3.4 Rules

3.4.1 Forward rules

3.4.2 Backward rules

3.4.3 Easy f and Easy b rules

SECTION 4: CERTAINTY FACTORS

SECTION 5: ADDING COMMENTARY TO INTERMODELLER EXPERT

SYSTEMS

SECTION 6: JUSTIFICATION

6.1 Why Justification

6.2 How Justification

SECTION 7: COMPARING MODELS

7.1 Transforming models

7.2

Slimming models

SECTION 8: EXERCISES ON INTERMODELLER

8.1 Exercise 1 (knowledge)

8.2 Exercise 2 (practical)

SECTION 9: APPENDIX 1: Eating Out Advisor Implementation

APPENDIX 2: Answers to Exercise 1

1. TEACHER NOTES

These InterModeller notes assume that students have been introduced to artificial intelligence and the theory of expert systems; that they are familiar with terms such as domain, knowledge base, knowledge engineer and inference engine.

The notes are designed to give students an introduction to InterModeller and the facilities it offers to explore the different ways used in artificial intelligence to model or represent knowledge. The knowledge domains used as examples in the notes are sufficient only to do this. They do not reach the complexity of domains appropriate to

Higher.

Features and facilities of InterModeller are introduced gradually through the notes.

Teachers/lecturers may wish to advise students that a feature introduced under one model may be available in other models.

Students are given names for saving their files. If this is likely to cause difficulty in identifying individual student’s files, teachers/lecturers are asked to advise their students accordingly.

The Appendix contains a possible solution to the Eating Out exemplar from the support materials for the unit: Artificial Intelligence at Higher.

Computing: InterModeller Notes for Artificial Intelligence (H) 1

2. INTRODUCTION TO INTERMODELLER

InterModeller is an expert system shell which is implemented in Prolog. It has 4 different ways of representing knowledge:

 decision trees

 tables

 classification trees

 rules.

Each of the different representations can be used to represent the same knowledge, although, one may represent the knowledge better than others. Each has different advantages and disadvantages which should be taken into account before deciding which representation to use.

InterModeller is designed mainly for classifying, although it can also be used to diagnose and give advice. It is not designed to give advice on planning.

Computing: InterModeller Notes for Artificial Intelligence (H) 2

3. CREATING EXPERT SYSTEMS USING INTERMODELLER

3.1 Decision trees

A decision tree is a graphical method of representing knowledge. Each representation is made up of nodes and arcs. Each branch of a decision tree contains a node, an arc and a child node. A node represents a question, an arc represents an answer and a child node represents either a decision or question.

Structure of a decision tree: node node arc arc child node child node

It is unlikely that all decisions can be made after answering just one question. Further questions may need to be asked before a decision can be reached. In such cases, further branches have to be added to the tree and the child node will contain a question instead of a decision.

Computing: InterModeller Notes for Artificial Intelligence (H) 3

Create an expert system using a decision tree

You have to create an expert system to advise your friends how to spend their

Saturday afternoon. The type of outing that the expert system will recommend will depend on what the weather is like and whether your friends have any money to spend. If it is wet and they have some money then they could go to the cinema. If they have no money, they could get in free to a museum or library. If it is a dry day and they have money, they could go to an outdoor market to do some shopping. If they do not have any money, they could go for a walk in the park instead. If it is snowing, people who have money could go skiing to Glenshee. Those who have no money could go sledging.

We are going to represent this information in a decision tree, so we need to decide which question to ask first. The first decision tree we are going to create will start with the question “How much money do you have?”

 run the InterModeller software. The screen will prompt you to create a new model or open an existing expert system.

 click on Decision trees then New model .

A blank decision tree window will now be displayed:

Computing: InterModeller Notes for Artificial Intelligence (H) 4

To add the first question:

 click on the text click here to supply a question . A clear box will appear at the top of the window.

 type in: How much money do you have?

 press enter or click Ok .

 click on the first node and a child node will appear at the foot of the arc.

 click on Answer on the arc and type: I have no money

To add a second question:

 click on Click here and type: What is the weather like?

 press enter or click Ok

 click on this node, another arc will appear

 click on Answer on the new arc

 type in: Snowy as the first answer

Computing: InterModeller Notes for Artificial Intelligence (H) 5

 press enter or click Ok

 click on What is the weather like?

node again to add a further two answers for

Dry and Wet.

To add decisions:

 click on Click here on the child node for Snowy

 type in: Go sledging

 press enter or click Ok .

 add the decision for wet weather: Go to the library or museum

 add the decision for dry weather: Go for a walk in the park

Your decision tree should now look like:

To add the I have some money answer to the tree:

 click on the node How much money do you have?

and another child node should appear

 press enter or click Ok

 click on Answer and type: I have some money

Computing: InterModeller Notes for Artificial Intelligence (H) 6

We are going to have to add the question about the weather to this branch of our tree.

Instead of doing this manually, we can copy the node that we created earlier and paste it onto this branch:

 click on the arrow tool on the left side of the screen

 click on the node: What is the weather like?

 in the Edit menu click on Copy

 click on Click here for I have some money

 in the Edit menu click on Paste .

Once you have pasted on the second branch your decision tree might look a bit crushed and it may be difficult to see the decision for each answer. Before we continue we are going to move the new branch to the right in order to see it properly.

 click on the arrow tool

 click on the node What is the weather like ? on the I have some money arc

 hold the mouse button down and drag the node over to the right slightly.

Change the decisions for this branch by clicking on the decisions and typing the following decisions on top:

 click on the pen tool

 enter the following decisions: wet – Go to cinema so that you can insert text again snowy – Go to Glenshee skiing dry – Go shopping at the outdoor market

Your decision tree should now look like:

Computing: InterModeller Notes for Artificial Intelligence (H) 7

To delete any nodes you have added by mistake:

 click on the eraser tool

 click on any node which is not required.

To save the decision tree:

 click on Save in the File menu.

 save as outingdtree1 .

To test the model

 click on Run in the Models menu.

 test your model thoroughly for each decision possible.

Does it matter the order in which facts are represented?

Yes it does. How the facts and rules are entered will determine the efficiency of the expert system.

What would happen in the outingdtree1 example if the questions were asked the other way around? Would the expert system work differently if the question “What is the weather like?” was asked first instead of “How much money do you have?”

Create another decision tree for this task, this time starting with the question “What is the weather like?”

Save this Decision tree as outingdtree2 . The decision tree should look like:

Test this new model. It produces the same decisions as the first one, the only difference being that the questions are asked in a different order.

Computing: InterModeller Notes for Artificial Intelligence (H) 8

Even though the second model still asks the same two questions, notice that by asking the question on weather first we have an additional node on our decision tree. The first decision tree outingdtree1 uses a total of 9 nodes and outingdtree2 uses 10 nodes. A good decision tree is one in which the number of nodes is kept to a minimum.

Check the properties of outingdtree1 and outingdtree2 and write down the size of each file. You should find that outingdtree2 is slightly larger than outingdtree1 . The extra node means that the model takes up more memory.

Therefore, it is important for knowledge engineers to consider the order in which questions are asked before creating an expert system model.

Computing: InterModeller Notes for Artificial Intelligence (H) 9

3.2 Tables

A table, made up of columns and rows, is another way to represent knowledge in

InterModeller. Tables are good for representing knowledge that can be classified.

The first row of the table contains the names of the attributes and the class name appears in the last column. These make the column headings of the table. For example, the table below represents information about snakes. The attributes that are used to distinguish different snakes are colour, length, and habitat . These appear in the first row with the class snake appearing last. Underneath the column headings is the value or the rule for the attribute for each class of snake. Each row of a table represents one class or conclusion.

When the model is run, the inference engine of the expert system starts by asking a question based on the attribute in the first column and then works its way along the table headings from left to right. The order in which the attributes are displayed determines the order in which the questions are asked. Again, the order of the attributes in the table determines the efficiency of the expert system.

When the above model is run, the question about colour will be asked first, followed by a question on length and then on habitat .

If there is no value known or required for an attribute of a particular class then an asterisk can be used as a “don’t know” or “not required” value. The length of a

Harlequin coral snake is unknown so an asterisk has been entered as the value in the length attribute.

To create a table:

 run InterModeller

 click on Tables at the bottom and then on New Model

 click Ok .

Computing: InterModeller Notes for Artificial Intelligence (H) 10

To create a table for the snake expert system:

 click anywhere inside the table that appears on the screen

 enter the information as illustrated in the table above

 save the expert system as snakestable .

Once you have created the table, test the model for all the different classes of snakes.

Dealing with OR and NOT in a table

InterModeller does not use these operators in any of its models. Instead an additional separate entry is made. In a table, that would mean that an extra row is added and the class would appear in two rows. For example, if the Mamba snake could be brown

OR black in colour, an extra row would be added to the table with black in the colour attribute and the same values appearing for the length and habitat attributes.

Create an expert system using a table

Aliens have landed from Mars, and they are trying to learn about different fruits.

Create an expert system using a table which identifies fruit. Use at least 10 different fruits. Save the model as fruittable .

Computing: InterModeller Notes for Artificial Intelligence (H) 11

3.3 Classification trees

Classification trees are similar to decision trees in that they both use a branching structure. Classification trees contain names and features of classes, subclasses and class members.

Classification trees can be used to arrange information into groups which share common features. A feature is a description of an item containing an attribute and value.

For example if an animal is to be classified as being a bird, it must have feathers as a covering, as the common feature of birds is having feathers as a cover.

Features are written as follows: covering is feathers

Covering - the attribute is – the relationship between the attribute and the value feathers – the value

Structure of classification tree

Unlike decision trees, the branches of classification trees are hierarchical and in

InterModeller the nodes are indicated by red squares.

The name of the class is displayed in normal text and the feature of the class is shown in italics.

Name of subclass

Name of class member

Class name

Feature of class

Feature of class member

Feature of subclass

Computing: InterModeller Notes for Artificial Intelligence (H) 12

A subclass of the class Bird could be Flightless and a class member could be the

Ostrich, which is a flightless bird.

Create an expert system using a classification tree

We are going to create an expert system to classify vehicles of transport. We will concentrate on methods of transport which use wheels and we will use the following information:

Car – 4 wheels, maximum number of passengers is 5, fuel is petrol

Bus – 4 wheels, maximum number of passengers is 50, fuel is diesel.

Bicycle – 2 wheels.

Taxi – 4 wheels, maximum number of passengers is 5, fuel is diesel.

Just as in using a decision tree, it is important in classification trees to identify the order in which to arrange the knowledge.

In our example, note that the only method of transport which has less than 4 wheels is a bicycle. In order to be able to identify or eliminate this mode of transport quickly, we can ask the question on the number of wheels first. Thus, to identify or classify a mode of transport which may be a bicycle will take one question.

Out of the 3 classes or conclusions left - car, bus, taxi - notice that a car is the only mode of transport which uses petrol. This means that if the second question is about fuel, then we can use the answer to identify whether or not we are dealing with a car; the information about the maximum number of passengers is not necessary in order to identify that the mode of transport is a car.

 run the InterModeller software

 click on Classification trees and then on New model .

Computing: InterModeller Notes for Artificial Intelligence (H) 13

The following window will appear:

 click on the text Click here to name this class!

, and a white text box will appear at the top of the window.

 type in: vehicle(mode is wheels).

 press enter or click Ok .

Vehicle should appear in normal font and underneath mode is wheels should appear in italics.

Vehicle is the name of the class and mode is wheels is the feature of this class. The feature must be put into brackets otherwise it does not recognise the feature and just adds the text to the name of the class.

To add subclasses:

 click on the red node to add a child node

 click on Click here to name this class!

and type in: bicycle(no of wheels is 2)

 press enter or click Ok

 add another child node by clicking again on the red node and type: 4 wheels(no of wheels is 4)

 press enter or click Ok

 add a child node to 4 wheels node and type: car(fuel is petrol)

 press enter or click Ok .

Continue until the classification tree looks like the following:

Computing: InterModeller Notes for Artificial Intelligence (H) 14

Save the classification tree as vehiclectree . Run the model to make sure that it works.

It is important that the attribute of the feature is the same in all branches at the same level of the classification tree. Bicycle has the attribute no of wheels and 4 wheels also has the attribute no of wheels . They both share no of wheels , but they each have a different value. Otherwise there would be no need to create 2 different subclasses at this point.

If the attribute of the feature is not the same then the expert system treats the two attributes as distinct and will ask a question on each.

 open vehiclectree

 run the model again.

Computing: InterModeller Notes for Artificial Intelligence (H) 15

Note that after answering Yes to the question about the mode, the expert system asks the question about the number of wheels. It gives two options, 2 or 4. This model only asks the question about the number of wheels once. Now let’s see the effect of running the model with different attributes in the same feature. Firstly, we have to change one of the attributes.

 click on Cancel to stop the consultation

 in the Classification tree change the attribute no of wheels in the bicycle class to: wheels

 press enter or click Ok

 run the model again

 click on Yes to the question about mode.

This time the model asks Wheels is 2? Instead of offering the values 2 and 4 it only asks the user to enter yes or no.

 click No

 click Ok .

Computing: InterModeller Notes for Artificial Intelligence (H) 16

The expert system now asks if the no of wheels is 4.

The expert system thinks that there are 2 different attributes in this model: no of wheels and wheels . That is the reason it asks the question twice.

To make sure that your model is efficient be careful how the features are worded.

Computing: InterModeller Notes for Artificial Intelligence (H) 17

3.4 Rules

3.4.1 Forward Rules

Rules are the traditional method of entering knowledge into an expert system shell.

Forward rules start with the condition(s) and end in the conclusion. Knowledge is represented using rules which have the structure:

IF condition THEN conclusion.

Writing a rule to discover whether a coin is a two pence piece or not might look like:

IF colour is bronze AND diameter is 25mm

THEN coin is two pence.

Note that conditions and conclusions both take the form:

Attribute is/are value .

A similar way to represent this rule is:

IF colour = bronze AND diameter = 25 mm

THEN two pence = true.

Again, conditions and conclusions are written in the same form.

The conclusion is reached and given after the expert system has tested and found all conditions to be true.

Rules can be typed directly into the model in this format. When creating the rules it is important that:

 the syntax is correct;

 conditions are separated by AND;

 and a full stop is added to the end of each rule.

Also, it is normal practice to put each condition on a separate line for easy reading.

This method of reasoning is called forward chaining where the system starts with the conditions and eventually gives a conclusion.

Create an expert system using forward rules

To create an expert system to identify coins that a person may have in their pocket.

 run the InterModeller software

 click on Forward rules then on New Model

A blank window will appear. No icons are used and we have to type the rules into the window.

Computing: InterModeller Notes for Artificial Intelligence (H) 18

First of all we need to identify the attributes and values for each coin. It is better to notes these in the same order for each class to ensure you cover all details and to make for easy reading.

Fifty pence coin – colour is silver, shape is 7 sides, size is 28mm diameter.

Twenty pence coin – colour is silver, shape is 7 sides, size is 21mm diameter.

Ten pence coin – colour is silver, shape is round.

Two pence coin – colour is bronze, shape is round, size is 25mm diameter.

One pence coin – colour is bronze, shape is round, size is 20mm diameter.

Each class or conclusion has one set of rules, which may be made up of one or more conditions. In this example there should be 5 rules, one for each class of coin. The order in which questions are asked is determined by the first rule and the first condition in that rule. Later we will think about which order would be better in this case but let’s just practice typing in rules first.

Click inside the blank window and type in the following rules:

IF colour is silver AND shape is 7 sides AND size is 28mm

THEN coin is fifty pence.

IF colour is silver AND shape is 7 sides AND size is 21mm

THEN coin is twenty pence.

IF colour is silver AND shape is round

THEN coin is ten pence.

IF colour is bronze AND shape is round AND size is 25 mm

THEN coin is two pence.

IF colour is bronze AND shape is round AND size is 20 mm

THEN coin is one pence.

Save the model as coinfrules and run the model, testing that each rule works correctly.

How could this model be made more efficient? The rule which distinguishes one coin from the other is size. If the colour of the coin you are trying to identify is bronze, there are only two possible conclusions: two pence or one pence.

Computing: InterModeller Notes for Artificial Intelligence (H) 19

In this case the rule about the shape of the coin is not necessary, as the conclusion can be reached using only the two rules for size and colour. The model at present takes three questions to come to the conclusions two pence or one pence.

 delete the condition shape is round from the rules for two pence and one pence

 run the model and test the rules for one pence and two pence.

Notice that the expert system now only takes 2 questions to get to the same conclusion.

Computing: InterModeller Notes for Artificial Intelligence (H) 20

3.4.2 Backward Rules

Backward rules, as the name would suggest, start with the conclusion then proceed to the conditions.

The rules have the following structure: coin is fifty pence

IF colour is silver AND shape is 5 sides AND size is 28mm.

Or it could be written:

Fifty pence = true

IF colour = silver AND shape = 5 sides AND size=28mm.

This method of reasoning is called backward chaining where the system starts with the conclusion and works back to prove the conditions true.

Using Rule Editor

Entering rules can be made easier by using the Rule Editor feature of InterModeller.

Instead of typing the rules directly into the blank window they can be entered into the rule editor which constructs the rule correctly and automatically enters the necessary formatting for rules.

Rule editor is found in the Models menu in the top bar.

Computing: InterModeller Notes for Artificial Intelligence (H) 21

Create an expert system using backward rules

Using the example for the coins, create a model using backward rules and the Rule

Editor:

 run InterModeller software

 click on Backward rules and New model

 click Ok

 in the Models menu, click on Rule Editor

 type in the first rule as follows:

 click on Paste

 repeat this process for all 5 rules, then add a further rule for the £1 coin

The screen should look like:

 save the model as coinbrules

 run the model.

Computing: InterModeller Notes for Artificial Intelligence (H) 22

Dealing with OR and NOT

As indicated before, InterModeller does not really use these operators in its language.

Instead a separate rule is written. For example a £2 coin is made up of two colours: gold and silver. To add this to our expert system we have to write 2 sets of rules for the £2 coin:

Coin is £2

IF colour is silver AND

Shape is round AND

Size is 20 mm.

Coin is £2

IF colour is gold AND

Shape is round AND

Size is 20 mm.

Insert these rules into the coinbrules model and save the model. Run the model and test for £2.

3.4.3 Easy b rules and Easy f rules

InterModeller has these two additional models which ease the writing of rules. The layout of the screen is the same as the other rule models. However, they allow a more extensive use of language so that when the model is run it can use proper sentences, making a more user friendly interface. The knowledge engineer does not need to use

IS/ARE or = in the condition and so when it comes to run time the questions make more sense to the user.

An example of an Easy B rule is:

Computing: InterModeller Notes for Artificial Intelligence (H) 23

An example of an Easy F rule is:

Note, however, that it is still important to use the same wording in the corresponding conditions/conclusions in etch rule.

Create an expert system using easy f or easy b rules

Using either an Easy f rule model or an Easy b rule model, create an expert system to advise people which radio station they should listen to. Your model should include at least 8 radio stations. Save the model as radioeasy . Run the model and test all the conclusions.

Computing: InterModeller Notes for Artificial Intelligence (H) 24

4. CERTAINTY FACTORS

Certainty factors can be added to rules to show the knowledge engineer’s confidence in the conclusion or decision. Certainty factors are added after each conclusion, for example:

Coin is fifty pence IF

Colour is silver AND

Shape is 5 sides AND

Size is 28mm

CF 90.

This means that the knowledge engineer is 90% certain that a silver coin with 5 sides is a fifty pence coin. Perhaps they are not 100% certain because the rules have not asked the question if the currency is Sterling.

Create an expert system using certainty factors

The performance of tennis players at tournaments is often affected by two factors, the weather and the type of court. For example, Tim Henman perhaps plays better on grass courts in cool climates, whereas Mark Phillipousis might perform better on clay courts in hot weather.

Open a new forward rules model and enter in the following rules:

IF condition is hot AND court is clay

THEN winner is Mark Phillipousis

CF 90.

IF condition is hot AND court is grass

THEN winner is Pete Sampras

CF 90.

IF condition is cool AND court is indoor

THEN winner is Andre Agassi

CF 70.

IF condition is cool AND court is grass

THEN winner is Tim Henman

CF 75.

IF condition is hot AND court is indoor

THEN winner is Greg Rusedski

CF 70.

Computing: InterModeller Notes for Artificial Intelligence (H) 25

IF condition is hot AND court is grass

THEN winner is Pat Rafter

CF 65.

 save the model as tenniscfrules

 run the model

 test expert system for Pete Sampras

When the model is run, the certainty factors are not displayed automatically. To find out what certainty factor the knowledge engineer entered for this outcome, click on the How button:

How is a justification feature of InterModeller which justifies the advice given by the expert system by showing how it reached the conclusions. It also shows the certainty factor used if one was given by the knowledge engineer. Note that the expert system simply traces the rule(s) for which all the conditions were met. It does not try to explain the rule(s) or the appropriateness of these rules.

In the model there are two conclusions which have the same two conditions. Pat

Rafter, as well as Pete Sampras, likes playing in hot weather on grass. This means that there should be two conclusions reached for these two conditions.

Computing: InterModeller Notes for Artificial Intelligence (H) 26

To view the other conclusion:

 click on the Go on button to return to the previous advice screen

 click on the More button to see if the expert system offers another conclusion.

The interface should tell us that winner is also Pat Rafter.

 click on the More button again to see if there are any other conclusions.

The following screen will appear:

Computing: InterModeller Notes for Artificial Intelligence (H) 27

 click on the Review button and the following screen will appear:

The user of the expert system can also use certainty factors to indicate their confidence in the answers that they are providing to the expert system. For example, the user may think that the condition is only ‘a little hot’ rather than ‘hot’, so he or she can qualify a Yes answer to the question ‘condition is hot?’ by a CF of 60.

Let’s see how this works. Firstly, the preferences of InterModeller have to be changed:

 in the File menu, click on Preferences

 click on Certainty handling is off

 change it to on

 click Set .

Computing: InterModeller Notes for Artificial Intelligence (H) 28

 run the model to test again for Pete Sampras:

This time when the model is run, the inference engine goes through all the possible answers to each question, asking the user to enter a certainty factor. The user can choose a factor between +100, which is 100% true and –100 which is 100% false.

The expert system will then use these certainty factors with the ones entered by the knowledge engineer to calculate an overall % certainty.

 choose a factor for each question

The conclusion of the consultation might look like:

Computing: InterModeller Notes for Artificial Intelligence (H) 29

 click on More

InterModeller should also advise that the winner is Pat Rafter and give a different certainty percentage.

Even if the user enters the same CF value for Pat Rafter and Pete Sampras, the certainty factor for Pat Rafter will be lower than that of Pete Sampras because the certainty factor entered by the knowledge engineer in the rules was lower for Pat

Rafter than Pete Sampras.

Computing: InterModeller Notes for Artificial Intelligence (H) 30

5. ADDING COMMENTARY TO INTERMODELLER EXPERT SYSTEMS

Comments can be added to models to explain what the expert system does and any other important details. Comments cannot be added to all the models available in

InterModeller; the only ones which support comments are all the rule models and tables.

In forward or backward rules, at the beginning of the model the comments need to be contained within the symbols /* at the start of the comments and */ at the end of the comments.

Comments can also be added in the middle of the model after a rule by using the % symbol before the comment.

To add comments at the beginning of the coinsfrules expert system:

 open the coinsfrules model

 at the top of the window before the first set of rules press return twice to make a space for the comments.

 type the following into the space: /* your name, date and this model will identify what type of coin you have in your pocket based on its colour, size and shape. */

To add comments to a set of rules:

 click after the size is 25mm for the two pence coin rule

 press the space bar until the cursor is half way along the line

 type in the following: % shape rule is not required because both 2p and 1p are round

Run the model again. If you have not entered the correct symbols in the correct place the model will not run.

Save the model.

In a table model comments can be added by entering information into one of the cells either underneath the table or above the table. If you are using more than one cell for your comments, the information must be entered into the next cell in the same row, otherwise InterModeller treats the information as a new table.

Computing: InterModeller Notes for Artificial Intelligence (H) 31

To add comments at the end of the snakestable :

 open the snakestable model

 click inside the cell two rows below the last row of the table, as indicated in the diagram below.

 type in your name

 click inside the next cell on the same row

 type in today’s date.

Run the model. If you have not entered the information in the correct place, the model will not run.

Save the model.

Computing: InterModeller Notes for Artificial Intelligence (H) 32

6. JUSTIFICATION

6.1 Using the How Justification

As shown earlier, this feature of most expert systems is used when the consultation is complete. It justifies the advice given by the expert system by using backward chaining to look back at the answers provided during the consultation, to display the rule(s) in which the answers indicated that all conditions were met.

Here is an example of How justification using the tennis expert system:

The full text inside this window is:

The advice was reached as follows.

It was shown that: winner IS Mark Phillipousis using the rule:

IF condition IS hot AND court IS clay

THEN winner IS Mark Phillipousis

CF 50 .

You said that: condition IS hot CF 60

You said that: court IS clay CF 100

This justifies the advice.

Computing: InterModeller Notes for Artificial Intelligence (H) 33

6.2 Using the Why Justification

This feature of most expert systems allows the user to make the expert system explain the relevance of a question asked during the consultation. This can be used in

InterModeller while the consultation is being run by clicking on the Why button in the question window. InterModeller then takes each rule in the model and tries to confirm that rule by seeking advice to support it.

For example, by clicking on the Why button while answering the question on the weather condition in the tennis expert system, InterModeller will say:

It justifies the question about the condition being hot because it may be able to advise that Mark Phillipousis will win, if the condition is hot (and the court is clay).

This feature can be used by the knowledge engineer when testing the model to check that it runs as it should.

Computing: InterModeller Notes for Artificial Intelligence (H) 34

7. COMPARING MODELS

Once a knowledge engineer has gathered the knowledge for the domain, it is necessary to decide on which representation to use. The knowledge engineer will consider the type of expert system that is to be created, the type of information to be stored and the kind of users of the expert system.

When considering the domain of the expert system, the knowledge engineer must also consider future implications, for example, whether the current knowledge is complete or whether the knowledge will be expanded at a later date. After such considerations, he may still make some wrong decisions. Intermodeller provides two features to help him make changes.

7.1 Transforming models

Certain types of knowledge models can be automatically transformed into another type of model by using the Transforming feature of InterModeller. Transforming a model into another model may be necessary if the original model used was not appropriate to represent the knowledge domain of the expert system. Additionally, a model may need to be transformed if the model used makes it difficult to expand the model or validate the knowledge. For example, a knowledge engineer can only express an opinion about the certainty of rules being true if the model used is either forward or backward rules. So if a knowledge domain is represented using a decision tree, certainty factors cannot be introduced. In this case, it may be better to transform the knowledge domain into rules so that certainty factors can be used.

There are only certain conversions that will work. It can be difficult to transform a rules model into a classification tree because the source does not have a hierarchical structure.

The Transform feature can be found in the Models menu. It can only be used if an expert system is already loaded.

When transforming one type of model into another, InterModeller will open a new window for the new model.

Computing: InterModeller Notes for Artificial Intelligence (H) 35

Transforming a forward rule model into a decision tree

 open the tenniscfrules

 in the Models menu click on Transform

 click on Decision trees as the required model type

 click Ok .

The following window should now be displayed:

 save the new model as tennistree

 run the model.

7.2 Slimming models

As well as transforming a model into a different type, it is also possible for

InterModeller to make a model more efficient by using the Slim to essentials feature, also found in the Transform window of the Models menu.

The Slim to essentials feature may have the effect of making the model more efficient by removing unnecessary rules, or rearranging the order in which questions are asked. It can be used to evaluate your first model and therefore can be helpful in planning future expert systems.

Computing: InterModeller Notes for Artificial Intelligence (H) 36

8.

EXERCISES ON INTERMODELLER

8.1

Exercise 1

1.

You should now be aware that InterModeller has many representations which can be used to represent knowledge in an expert system: decision trees, tables, classification trees, forward rules, backward rules, easy f rules and easy b rules.

For each of the cases below choose a suitable representation or representations and justify each of your answers: a.

A certainty factor is required for each of the outcomes in an expert system. b.

A knowledge engineer wants to use proper English to create an expert system for users who do not have much experience of computers. c.

Creating an expert system to identify types of rock. d.

Internal comments must be able to be added to the expert system. e.

Creating an expert system which diagnoses printer problems. f.

A student wishes to create an expert system but is not familiar with programming rules.

2.

How does InterModeller deal with AND, OR and NOT?

3.

How can InterModeller help to make an existing expert system more efficient?

4.

Which InterModeller feature would you use if you were not sure why the expert system is asking you a particular question?

5.

If you were unsure of the conclusion an expert system provided you with, which InterModeller feature could you use to check that the conclusion is correct.

6.

Investigate which InterModeller representations allow more than one solution for the same set of conditions.

Computing: InterModeller Notes for Artificial Intelligence (H) 37

8.2 Exercise 2

7.

Carry out the slim to essentials on the fruittable expert system. Then transform it into a table. Save this new model as fruittable2 and obtain a printout of both fruittable and fruittable2 .

8.

Compare the original model with the slimmed version. How has

InterModeller improved the model?

9.

Transform fruittable2 model again into another type of representation.

Save the new model as fruit3 . Print fruit3 . Compare the two different models. Which one do you prefer and why?

Computing: InterModeller Notes for Artificial Intelligence (H) 38

APPENDIX 1

Eating Out Advisor Implementation

The following is part of the sample solution for the Eating Out Advisor provided in the Artificial Intelligence support notes. This section covers the latter steps of the solution: representing domain knowledge; implementing the system; and testing the system.

Gathering of domain knowledge

The following table is created from the information on page 96 of the Artificial

Intelligence support notes.

Place Name

Price –

Cheap,

Middle or

Expensive

Place Type –

Café, Tea

Room, Bar or

Restaurant Licensed?

Food – Café Food,

Snacks, Bar Food,

Bar Supper, Italian,

Indian, Chinese,

Mexican, French or

British

Joe’s Café cheap café no café food

The Copper Kettle cheap tea room no snacks

The Grub Spot

The Smugglers Inn

The Sailors Rest

Milanos cheap middle middle middle restaurant bar bar restaurant yes yes yes yes

British bar lunch bar supper

Italian

The Taj Mahal

The Peking Rose

Les Grenouilles

Muchachos Mexican middle restaurant expensive restaurant expensive restaurant expensive restaurant no yes yes no

Indian

Chinese

French

Mexican

Computing: InterModeller Notes for Artificial Intelligence (H) 39

Representing domain knowledge

This knowledge can be represented in InterModeller using the forward rules:

IF Price = cheap AND

Place type = cafe AND

Licensed = no AND

Food = cafe food

THEN Place name = Joe's cafe.

IF Price = cheap AND

Place type = tea room AND

Licensed = no AND

Food = snacks

THEN Place name = The Copper Kettle.

IF Price = cheap AND

Place type = restaurant AND

Licensed = yes AND

Food = British

THEN Place name = The Grub Spot.

IF Price = Middle AND

Place type = bar AND

Licensed = yes AND

Food = bar lunch

THEN Place name = The Smugglers Inn.

IF Price = Middle AND

Place type = bar AND

Licensed = yes AND

Food = bar supper

THEN Place name = The Sailors Rest.

IF Price = Middle AND

Place type = restaurant AND

Licensed = yes AND

Food = Italian

THEN Place name = Milanos.

IF Price = Middle AND

Place type = restaurant AND

Licensed = no AND

Food = Indian

THEN Place name = The Taj Mahal.

Computing: InterModeller Notes for Artificial Intelligence (H) 40

IF Price = expensive AND

Place type = restaurant AND

Licensed = yes AND

Food = Chinese

THEN Place name = The Peking Rose.

IF Price = expensive AND

Place type = restaurant AND

Licensed = yes AND

Food = French

THEN Place name = Les Grenouilles.

IF Price = expensive AND

Place type = restaurant AND

Licensed = no AND

Food = Mexican

THEN Place name = Muchachos Mexican.

Implementing the system

 open a new forward rules model

 enter the above rules

 save the model as eatingrules.

Testing the system

 copy and fill in the table with the following test data, adding another 3 sets of test data.

 run the model and test the system using the test data

 enter into the table the actual result of each test.

TEST DATA EXPECTED RESULT ACTUAL RESULT cheap, restaurant, licensed and British. The Grub Spot The Grub Spot

Computing: InterModeller Notes for Artificial Intelligence (H) 41

APPENDIX 2

Answers to Exercise 1

1.

a.

Forward rules, backward rules, easy f rules or easy b rules. Certainty factors cannot be used in any other representation in InterModeller. b.

Easy b or Easy f rules can be used as they allow a more extensive use of language so that when the model is run it can use proper sentences. c.

Classification tree or table can be used. Classification trees are good at representing knowledge which is hierarchical. The attributes can be easily displayed in a table. d.

Comments can be added to tables or any of the rule models. e.

Decision trees are very good at representing exceptional knowledge and so that makes them good for diagnosing. However, any representation could be used apart from a classification tree. f.

Decision tree, or Easy f or Easy b rules. The student does not need to use specific syntax.

2.

A separate rule is written, to deal with AND , OR and NOT .

3.

By using the Slim to essentials feature.

4.

Use the Why justification when the question is asked.

5.

Use the How justification at the end of the consultation.

6.

Classification tree is the only representation which is not able to provide more than one solution for the same set of conditions.

Computing: InterModeller Notes for Artificial Intelligence (H) 42

Download