+ All Categories
Home > Documents > Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

Date post: 09-Jan-2016
Category:
Upload: etenia
View: 53 times
Download: 7 times
Share this document with a friend
Description:
Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc. Structure of a rule-based expert system development software. Sample Problem. A business uses the following temperature control policy in a work environment. - PowerPoint PPT Presentation
27
1 Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc
Transcript
Page 1: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

1

Building a Knowledge Basewith VPExpert (VPX.exe)

see also: vpxguide.doc

Page 2: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

2

Structure of a rule-based expert system Structure of a rule-based expert system development softwaredevelopment software

User

ExternalDatabase External Program

Inference Engine

Knowledge Base

Rule: IF-THEN

Database

Fact

Explanation Facilities

User Interface DeveloperInterface

Expert System

Expert

Knowledge Engineer

Page 3: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

3

Sample Problem

A business uses the following temperature control policy in a work environment.

In spring, summer, autumn and winter during business hours the thermostat settings are 20, 24, 20 and 18C respectively. In those seasons out of business hours the settings are 15, 27, 16 and 14C respectively. The spring months are September, October and November; summer months are December, January and February; autumn months are March, April and May, and winter months are June, July and August. The weekdays are Monday to Friday, and, Saturday and Sunday are weekend days. Business hours are between 9 am and 5 pm.

Page 4: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

4

Construct a knowledge base representing this policy.

1. Extract the goals

1. Decide on the facts

1. Construct the rules

Page 5: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

Structure of a Knowledge Base

5

Creating an expert system with VP Expert is basically a question of entering a knowledge base which consists of three parts:

ACTIONS RULESQUERY STAEMENTS

Page 6: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

6

Goals and the Actions Block

The FIND statement expresses the goal. The basic form of this statement is:

FIND variable

This statement activates the inference engine, causing it to consult the knowledge base of rules until a value is found for the variable.

FIND Thermostat_setting

Page 7: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

7

The Actions Block

1. The ACTIONS block consists of statements which control the actions of the shell.

2. These statements are executed in the order in which they appear.

3. In effect, the ACTIONS block is the `code' which controls the execution of the inference engine.

Page 8: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

8

Example: Actions Block

ACTIONS DISPLAY "Thermostat Setting~" FIND Thermostat_setting DISPLAY "Setting is {#Thermostat_setting}";

Note that it begins with the word ACTIONS and terminates with a semicolon (no semicolons between statements).

If you want to make sure that the user has time to read a message before it disappears from the screen, insert a "~" as the last character in the message.

Page 9: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

9

Production RulesThe basic form of a rule is as follows:

RULE rulename

IF antecedentTHEN consequent;

Every rule must have a unique name (up to 40 chars in length) after the word RULE.

Page 10: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

10

Example Rule

RULE Diagnosis_of_measles

IF Diagnosis = measles

THEN Treatment = penicillin;

In this case, Diagnosis and Treatment are variables, and measels and penicillin are potential values for those variables.

In other words, this rule states that if Diagnosis has the value measels we may then assign Treatment the value penicillin.

Page 11: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

Search Algorithm

11

If the inference engine was currently trying to use this rule to FIND a value for the variable Treatment, it would:

Check whether Diagnosis had already been assigned a value.

If not, it would use the rules to try to FIND a value for Diagnosis, returning to this rule once it has done so.

If the value of Diagnosis is measles, then Treatment is assigned the value penicillin. At that point, the inference engine does no more work n FINDing a value for Treatment.

If Diagnosis has some other value (including unknown), then the rule fails, and the inference engine must search for some other rule to give Treatment a value (if there is none, then Treatment is assigned the value unknown).

Page 12: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

12

Facts

Variables representing basic facts which do not appear as the consequent of some rule in the knowledge base (that is, are leafs in the deduction tree), are considered potential questions for the user.

If the inference engine attempts to FIND such a variable, the user will be prompted for its value.

This is done with ASK and CHOICES statements.

Page 13: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

13

Ask Statement

The form of the prompt for a variable is defined by an ASK statement. It has the form:

ASK variable: "prompt";

For example:

ASK Month : "Which month is it?";

As with any other program, these prompts should be informative -- that is, they should tell the user how to gather and enter the information.

Page 14: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

14

Choices Statement

CHOICES variable: list of values;

For example:

CHOICES Month : july, august;

A menu is printed out when the question is ASKed. Note that if there is no CHOICES statement for a variable, the user will have to type in a value at the cursor after the prompt (this is how numeric variables are usually handled).

Page 15: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

15

Rule 2 IF day = workday AND Time = between_9am_and_5pm THEN Operation = business_hours;Rule 3 IF Month = july THEN Season = winter;Rule 4 IF Season = winter AND Operation = business_hours THEN Thermostat_setting = 18_degrees;

More rules

Page 16: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

16

Simple Premises

The IF part of a rule consists of one (or more) simple premises of the form:

variable relational_operator value

where relational_operator is one of the following:

= is equal to <> is not equal to (used instead of NOT by VP-Expert) < is less than <= s less than or equal to > is greater than >= is greater than or equal to

The latter four operators are primarily used for numeric values

Page 17: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

17

Booleans

RULE fluIF throat = soreAND temperature = highOR temperature = very_highTHEN Diagnosis = flu;

is interpreted as (throat = sore) AND (temperature = high OR temperature = very_high).

Page 18: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

18

Variables

VP-Expert does not allow you to declare your variables.

It needs some way to tell a variable (such as diagnosis) from a value (such as measles) when used on the right side of the expression.

This is done by enclosing the variable on the right side of the expression in parentheses.

For example:

RULE own_pharmacyIF pharmacy_used = oursTHEN perscription = (treatment);

Page 19: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

19

Multiple answers to queries

The inference engine for VP-Expert will stop once it has found the first value of a variable it is trying to FIND.

It is possible, however, to force it to find all values for variables instead.

This is done with the PLURAL statement (which must be placed before the ACTIONS block):

PLURAL: thermostat_setting;

In the a medical knowledge base you wish to make treatment and diagnosis plural

Page 20: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

20

PLURAL inputs

It is also possible to set up your ASK statements to allow the user to choose more than one option from the menu by making that variable PLURAL.

This is often faster for the user than having to answer multiple questions. For example:

PLURAL: symptoms;...

ASK symptoms: "Choose all symptoms that you have.";

CHOICES symptoms: sore_throat, spots, rash, none;

The user can then press ENTER by each one which holds, and press END to confirm the list.

Page 21: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

21

!Thermostat ExampleACTIONS DISPLAY "Thermostat Setting~" FIND Thermostat_setting DISPLAY "Setting is {#Thermostat_setting}";Rule 1 IF Today = monday THEN day = workday;Rule 2 IF day = workday AND Time = between_9am_and_5pm THEN Operation = business_hours;Rule 3 IF Month = july THEN Season = winter;Rule 4 IF Season = winter AND Operation = business_hours THEN Thermostat_setting = 18_degrees;

ASK Month : "Which month is it?";CHOICES Month : july, august;ASK Time : "What time is it?";CHOICES Time : between_9am_and_5pm, before_9am;ASK Today : "What day is it";CHOICES Today : monday, tuesday;

Page 22: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

22

Explanation and the BECAUSE statement

RULE measlesIF temperature = very_highAND spots = yesAND innoculated <> yesTHEN Diagnosis = measlesBECAUSE "A high temperature and spots are the usual symptoms of measles";

The text contained if the BECAUSE statement is printed if this rule is involved in either a how or why query.

Page 23: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

23

Extracting Explanations for a Consultation

VP-Expert also allows you to see explanations of how a variable was set, or why a question was asked. This can be done when the program is running by pressing the / key (which halts execution temporarily) and then selecting the desired option from the menu.

If how is selected, VP-Expert will then provide a menu of the variables used in the program. It will then print the BECAUSE part (see below) of the rule used to give that variable its value (if any).

If why is selected, VP-Expert will print the BECAUSE part (see below) of the rule responsible for causing the current question to be asked.

Chest congestion and nasal congestion without the sore throat can also indicate pneumonia.”

IF chest_congestion = yes AND nasal_congestion = yesTHEN Diseases = pneumonia CNF 85;BECAUSE Chest and Nasal congestion are indicative of pneumonia

Page 24: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

24

Alternate Explanation

It is perhaps more user friendly to print explanations directly using DISPLAY statements:

RULE measlesIF temperature = very_highAND spots = yesAND innoculated <> yesTHEN Diagnosis = measlesDISPLAY "Your extremely high temperature and spots indicate a case of measles."

Page 25: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

25

Confidence Factors

Uncertainty in VP-Expert is represented in terms of ``confidence factors'' (abbreviated CNF), which may take on any value between 0 and 100.

These confidences apply to the assignments done by the inference engine -- for example, something of the form

diagnosis = flu CNF 80

means that the system believes that diagnosis has the value measles with certainty of 80 out of 100

RULE fluIF temperature > 99THEN diagnosis = flu CNF 80

Page 26: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

26

Certainty in VPExpert

Combining certainties of rules and premises

If both the premise (that is, the ``IF'' part) of a rule and the rule itself are uncertain, then the confidence of the conclusion of the rule is:

CNF of premise * CNF of rule / 100

VPExpert uses a minimum to compute the confidence of a conjunction and

To compute the confidence of a disjunction

cf1 + cf2 -(cf1 * cf2)

Page 27: Building a Knowledge Base with VPExpert (VPX.exe) see also: vpxguide.doc

27

Truth Thresholds

This is controlled with the TRUTHTHRESH value in VP-Expert. If the confidence in the premise of a rule is less than TRUTHTHRESH, then it fails and assigns no values. For example, given the rule

IF diagnosis = measlesTHEN treatment = penicillin;

If TRUTHTHRESH is 40, and the confidence in the premise diagnosis = measles is 35, then this premise is considered to be FALSE, and the assignment treatment = penicillin is not done.

The default value of TRUTHTHRESH is 50. It can be changed in the ACTIONS block or a rule conclusion. For example, to change the threshold to 40, you would use the statement:

TRUTHTHRESH = 40


Recommended