For new e2gRuleEngine/
e2gRuleWriter Web content
CLICK HERE
 
[Home: Demos and Tutorials][e2gLite Mini-Course Index]

Building and Using Expert Systems: a Mini-Course Introducing the e2gLite Expert System Shell

Module 7: Designing and implementing e2gLite knowledge bases that deliver your knowledge

Module 7 Index

In this final module, we'll use a hypothetical graduate school admission process as a case study to illustrate some ideas about knowledge base design, construction and debugging. A listing of the complete e2gLite graduate admissions knowledge base is included in the module for reference.

If you haven't already done so, taking a look at Module 6: Introduction to Knowledge Engineering is recommended because it provides supporting material for this discussion. We'll also assume that you have worked the examples in Module 4: Creating your first knowledge base so that you know how to enter a knowledge base and create a Web page that loads the e2gLite applet to access your rules.

Admissions recommendation logic: The logic for the example expert system is represented by the following flow chart:

Graduate Admissions Recommendation Logic

Framework: An expert system is developed in a conceptual framework that represents the problem domain. This structure supports the knowledge decomposition that leads to the definition of attributes and creation of rules as described in Module 6. Procedural examples like this admissions process are often documented in a flowchart or decision tree format when knowledge engineering begins. It is tempting to develop a rule to represent each path through the flow chart, but additional analysis that identifies and names subconcepts could produce a knowledge base that more clearly supports two of the justifications for using an expert system: the ability to explain why a recommendation was made and the ability to make a recommendation using a minimum amount of factual input.

Expert system outputs: A list of the possible admissions recommendations can be extracted from the flow chart:

  1. Admit with full status
  2. Admit with full status (special decision)
  3. Admit provisionally
  4. Admit provisionally with recommended remedial English coursework
  5. Refer to academic department for decision
  6. Admit conditionally (special decision)
  7. Wait for transcript before making decision
  8. Deny normal admission (could be reviewed)

Recommendations 1-5 are possible for students who have provided a final undergraduate transcript. Recommendations 6-7 are possible for students who have not provided a final undergraduate transcript. Recommendation 8 is possible whether or not the undergraduate degree has been completed.

Expert system inputs: Here is a grouped list of the attributes, identified from the flow chart, for which input PROMPTs will be written:

Certainty factors: Because these inputs are factual rather than opinions, certainty factor input will not be requested for any of the PROMPTs in this knowledge base: the optional CF parameter is not used in the PROMPTs.

Multi-valued attributes: There are four parameters representing special honors, and an applicant could possess any combination of these. The parameters are used in several rules, and the fact that an applicant possesses none of the attributes is also used in several rules. This set of circumstances is efficiently represented in an e2gLite knowledge base through the combined use of the AllChoice PROMPT along with the MAXVALS and DEFAULT statements:

PROMPT [the applicant] AllChoice
"This applicant is (check all that apply):"
"an honor student"
"an honor graduate"
"a class valedictorian"
"a class salutatorian"

MAXVALS [the applicant] 4
DEFAULT [the applicant] = "not the recipient of special honors"

The AllChoice PROMPT allows the knowledge base user to check any or all of the parameters describing the applicant's special honors. A MAXVALS statement allowing four values of the applicant must be included or values beyond the first one entered will be discarded.

It is often useful for a rule to detect the fact that no value can be found for an attribute. This is accomplished in e2gLite by employing the DEFAULT statement. The PROMPT for the applicant is the only source of values for this attribute. If none of the values are checked when the PROMPT is issued, the inference engine determines that the value cannot be resolved and the DEFAULT value "not the recipient of special honors" is assigned. Here is an example rule that will only fire for an applicant who has received no special honors:

RULE [Conditional eval, low GRE]
If [the evaluation] = "for a conditional decision" and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] < 1100
Then [the recommendation] = "wait for transcript" and
[the action] = "based on established policy"

Interim constructs: Knowledge bases are sometimes simplified and recommendation justifications clarified by using interim constructs to capture a common theme. The next pair of rules captures the logic in the flow chart that determines the need to examine the applicant's undergraduate GPR:

RULE [Consider undergraduate GPR (no grad credits)]
If [the applicant's graduate status] = "no prior graduate work completed"
Then [the undergraduate GPR should be considered] = true

RULE [Consider undergraduate GPR (grad credits)]
If [the applicant's graduate status] = "prior graduate work completed" and
[the applicant's GPR on prior graduate work] > 2.99
Then [the undergraduate GPR should be considered] = true
The contrived attribute the undergraduate GPR should be considered may then be used in rules like the following:
RULE [Deny because of undergraduate GPR]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] < 2.5
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"
Without this device, the following rules would be required to capture the same logic (and there are several similar rules that must determine whether to evaluate the undergraduate GPR):
RULE [Deny because of undergraduate GPR (no grad credits)]
If [the applicant's graduate status] = "no prior graduate work completed" and
[the applicant's GPR on last 60 undergraduate hours] < 2.5
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

RULE [Deny because of undergraduate GPR (grad credits)]
If [the applicant's graduate status] = "prior graduate work completed" and
[the applicant's GPR on prior graduate work] > 2.99 and
[the applicant's GPR on last 60 undergraduate hours] < 2.5
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

The knowledge base: the complete knowledge base is provided in the following table as a reference.

Graduate Admissions Knowledge Base
REM Graduate admissions demonstration expert system

REM Decide how to proceed

RULE [Language requirement] 
If [the applicant's UG status] = "receiving a bachelor's degree from a US institution" or
[the applicant's TOEFL score] > 499
Then [the language requirement] = "met"

RULE [Conditional consideration]
If [the language requirement] = "met" and
[the applicant's final undergraduate transcript] = "not available"
Then [the evaluation] = "for a conditional decision"

RULE [Full consideration]
If [the language requirement] = "met" and
[the applicant's final undergraduate transcript] = "available"
Then [the evaluation] = "for a full decision"

REM Conditional evaluation

RULE [Wait for transcript]
If [the evaluation] = "for a conditional decision" and
[the applicant's GPR on last 60 undergraduate hours] < 3.3
Then [the recommendation] = "wait for transcript" and
[the action] = "based on established policy"

RULE [Honor student]
If [the evaluation] = "for a conditional decision" and
[the applicant's GPR on last 60 undergraduate hours] > 3.29 and
[the applicant] = "an honor student" 
Then [the recommendation] = "admit conditionally" and
[the action] = "based on special decision"

RULE [Conditional eval, high GRE]
If [the evaluation] = "for a conditional decision" and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] > 1099
Then [the recommendation] = "admit conditionally" and
[the action] = "based on special decision"

RULE [Conditional eval, low GRE]
If [the evaluation] = "for a conditional decision" and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] < 1100
Then [the recommendation] = "wait for transcript" and
[the action] = "based on established policy"

REM Full evaluation

REM Deny

RULE [Deny because language requirement not met] 
If [the applicant's UG status] = "not receiving a bachelor's degree from a US institution" and
[the applicant's TOEFL score] < 500
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

RULE [Deny because of graduate GPR]
If [the applicant's graduate status] = "prior graduate work completed" and
[the applicant's GPR on prior graduate work] < 3.0
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

RULE [Consider undergraduate GPR (no grad credits)]
If [the applicant's graduate status] = "no prior graduate work completed"
Then [the undergraduate GPR should be considered] = true

RULE [Consider undergraduate GPR (grad credits)]
If [the applicant's graduate status] = "prior graduate work completed" and
[the applicant's GPR on prior graduate work] > 2.99
Then [the undergraduate GPR should be considered] = true

RULE [Deny because of undergraduate GPR]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] < 2.5
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

RULE [Deny because of undergraduate GPR and GRE]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.49 and
[the applicant's GRE score] < 900
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

RULE [Deny because of GRE]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.49 and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] < 900
Then [the recommendation] = "deny normal admission" and
[the action] = "based on established policy"

REM Provisional acceptance

RULE [Provisional acceptance: low GRE, verbal GRE]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.49 and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] > 899 and
[the applicant's GRE score] < 1100 and
[the applicant's GRE verbal score] < 400
Then [the recommendation] = "admit provisionally - recommend English remediation" and
[the action] = "based on established policy"

RULE [Provisional acceptance: low GPR, verbal GRE]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.49 and
[the applicant's GPR on last 60 undergraduate hours] < 3.0 and
[the applicant's GRE score] > 899 and
[the applicant's GRE verbal score] < 400
Then [the recommendation] = "admit provisionally - recommend English remediation" and
[the action] = "based on established policy"

RULE [Provisional acceptance: low GRE]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.99 and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] > 899 and
[the applicant's GRE score] < 1100 and
[the applicant's GRE verbal score] > 399
Then [the recommendation] = "admit provisionally" and
[the action] = "based on established policy"

RULE [Provisional acceptance: low GPR]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.49 and
[the applicant's GPR on last 60 undergraduate hours] < 3.0 and
[the applicant's GRE score] > 899
Then [the recommendation] = "admit provisionally" and
[the action] = "based on established policy"

REM Accept

RULE [Acceptance: honors]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.99 and
[the applicant] : "an honor graduate" "a class valedictorian" "a class salutatorian"
Then [the recommendation] = "admit with full status" and
[the action] = "based on special decision"

RULE [Acceptance at departmental discretion]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.99 and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] > 1099 and
[the applicant's GRE verbal score] < 400
Then [the recommendation] = "admission decision is at department's discretion" and
[the action] = "based on established policy"

RULE [Acceptance]
If [the undergraduate GPR should be considered] = true and
[the applicant's GPR on last 60 undergraduate hours] > 2.99 and
[the applicant] = "not the recipient of special honors" and
[the applicant's GRE score] > 1099 and
[the applicant's GRE verbal score] > 399
Then [the recommendation] = "admit with full status" and
[the action] = "based on established policy"

REM Prompts

PROMPT [the applicant's UG status] MultChoice
"This applicant is:"
"receiving a bachelor's degree from a US institution"
"not receiving a bachelor's degree from a US institution"

PROMPT [the applicant's TOEFL score] Numeric 
"What is the applicant's TOEFL (Test of English as a Foreign Language) score?"
"0"
"800"

PROMPT [the applicant's GPR on prior graduate work] Numeric
"What is the applicant's GPR (Grade point ratio) for prior graduate work?"
"0"
"4.0"

PROMPT [the applicant's final undergraduate transcript] MultChoice
"The applicant's final undergraduate transcript is:"
"available"
"not available"

PROMPT [the applicant's GPR on last 60 undergraduate hours] Numeric
"What is the applicant's GPR (Grade point ratio) for the last 60 UG hours?"
"0"
"4.0"

PROMPT [the applicant's graduate status] MultChoice
"This applicant's graduate status is:"
"prior graduate work completed"
"no prior graduate work completed"

PROMPT [the applicant's GPR on prior graduate work] Numeric
"What is the applicant's GPR (Grade point ratio) on prior graduate work?"
"0"
"4.0"

PROMPT [the applicant] AllChoice
"This applicant is (check all that apply):"
"an honor student"
"an honor graduate"
"a class valedictorian"
"a class salutatorian"

PROMPT [the applicant's GRE score] Numeric
"What is the applicant's total GRE (Graduate Record Exam) score?"
"0"
"1600"

PROMPT [the applicant's GRE verbal score] Numeric
"What is the applicant's GRE verbal score?"

GOAL [the recommendation]
GOAL [the action]

MAXVALS [the applicant] 4

DEFAULT [the applicant] = "not the recipient of special honors"


Delivering a knowledge base in languages other than English (requires e2gLite v2.0 or later: e2gSwing is recommended)

A typical approach to delivering applications in multiple languages is to first produce a version in a base language, then localize this version of the application for each target language. Once a base language (English is currently the only base language for e2gLite) version of a knowledge base has been developed and debugged, the following steps may be used to deliver it in another language:

Here's an example of the auto diagnosis knowledge base translated into French. This is the autofr.kb file referenced in the KBURL applet parameter in the HTML that loads the knowledge base. This is a machine translation and is therefore less polished than would be expected from an expert human translator. The English version of this knowledge base is available as the Example e2gLite Knowledge Base in the reference documentation.

REM Test knowledge base

RULE [La batterie est-elle morte?]
If [le résultat d'alimenter les phares] = "rien ne se produit" or
[le résultat d'essayer le démarreur] = "rien ne se produit"
Then [recommandée l'action] = "rechargez ou substituez la batterie"

RULE [La voiture est-elle hors d'essence?]
If [le réservoir d'essence] = "vide"
Then [recommandée l'action] = "réapprovisionnez en combustible la voiture"

RULE [La batterie est-elle faible?]
If [le résultat d'essayer le démarreur] : "les manivelles de voiture lentement" "les manivelles de voiture normalement" and
[les phares obscurcissent en essayant le démarreur] = true and
[la quantité vous êtes disposé à dépenser sur des réparations] > 24.99
Then [recommandée l'action] = "rechargez ou substituez la batterie"

RULE [La voiture est-elle inondée?]
If [le résultat d'essayer le démarreur] = "les manivelles de voiture normalement" and
[une odeur d'essence] = "présentez en essayant le démarreur"
Then [recommandée l'action] = "l'attente 10 minutes, relancent alors inondée la voiture"

RULE [Le réservoir d'essence est-il vide?]
If [le résultat d'essayer le démarreur] = "les manivelles de voiture normalement" and
[une odeur d'essence] = "pas présentez en essayant le démarreur"
Then [le réservoir d'essence] = "vide" @ 90

PROMPT [le résultat d'essayer le démarreur] Choice CF
"Que se produit quand vous tournez la clé pour essayer de mettre en marche la voiture?"
"les manivelles de voiture normalement"
"les manivelles de voiture lentement"
"rien ne se produit"

PROMPT [une odeur d'essence] MultChoice CF
"Une odeur d'essence et:"
"présentez en essayant le démarreur"
"pas présentez en essayant le démarreur"

PROMPT [le résultat d'alimenter les phares] MultChoice CF
"Le résultat d'alimenter les phares et:"
"ils s'allument"
"rien ne se produit"

PROMPT [les phares obscurcissent en essayant le démarreur] YesNo CF
"Les phares obscurcissent-ils quand vous essayez le démarreur avec les lumières?"

PROMPT [le réservoir d'essence] MultChoice CF
"Selon la mesure de carburant, le réservoir d'essence est:"
"vide"
"non vide"

PROMPT [la quantité vous êtes disposé à dépenser sur des réparations] Numeric CF
"Combien coûtez-vous disposé à dépenser sur des réparations? (0->500)"
"0"
"500.0"

GOAL [recommandée l'action]

MINCF 80

REM French translation
REM Button text 
TRANSLATE B_SUBMIT = "Soumettez votre réponse" 
TRANSLATE B_EXPLAIN = "Expliquent" 
TRANSLATE B_WHYASK = "Pourquoi demandez?" 
TRANSLATE B_RESTART = "Relancement" 
TRANSLATE B_RETURN = "Retournent" 
REM Message text 
TRANSLATE TR_KB = "Base de connaissance:" 
TRANSLATE TR_NORESP = "Je ne connais pas/ne répondrait plutôt pas" 
TRANSLATE TR_HOWCONF = "Que confiant pensez-vous de votre réponse?" 
TRANSLATE TR_LOWCONF = "Très incertain (50%)" "
TRANSLATE TR_HICONF = "Très certain (100%)" 
TRANSLATE TR_YES = "Oui" 
TRANSLATE TR_NO = "Non"
TRANSLATE TR_FALSE = "faux" 
TRANSLATE TR_RESULTS = "FINALS RÉSULTATS:" 
TRANSLATE TR_MINCF = "Facteur minimum de confiance pour recevoir une valeur comme fait:" 
TRANSLATE TR_NOTDETERMINED = "n'a pas pu être déterminé" 
TRANSLATE TR_ISRESULT = "est:" 
TRANSLATE TR_WITH = "avec" 
TRANSLATE TR_CONF = "% de confiance" 
TRANSLATE TR_ALLGOALS = "toutes les conclusions" 
TRANSLATE TR_VALUE = "Valeur" 
TRANSLATE TR_OF = "de" 
TRANSLATE TR_THISRULE = "Règle au-dessous de réussi à CF=" 
TRANSLATE TR_RULEASGN = "et assigné la valeur" 
TRANSLATE TR_TOFIND = "Pour trouver" 
TRANSLATE TR_AVALUE = "une valeur pour" 
TRANSLATE TR_ISNEEDED = "est nécessaire pour essayer cette règle:" 
TRANSLATE TR_RULE = "RÈGLE:" 
TRANSLATE TR_IF = "SI:" 
TRANSLATE TR_THEN = "ALORS:" 
TRANSLATE TR_AND = "et" 
TRANSLATE TR_OR = "ou" 
TRANSLATE TR_IS = "est" 
TRANSLATE TR_EQUAL = "est" 
TRANSLATE TR_LESSTHAN = "est moins qu'" 						 
TRANSLATE TR_NOTEQUAL = "n'est past" 
TRANSLATE TR_GREATER = "est plus grand qu'" 
TRANSLATE TR_VALUEFOR = "Une valeur pour:" 
TRANSLATE TR_FOUND = "a été déterminé" 
TRANSLATE TR_NOTFOUND = "n'a pas été encore déterminé" 
TRANSLATE TR_WASINPUT = "a été entré avec" 
TRANSLATE TR_DETERMINED = "Déterminé" 
TRANSLATE TR_FROM = "de:" 
TRANSLATE TR_DEFAULTED = "a été placé par défaut avec" 
REM following added in v3.03
TRANSLATE TR_ONE = "une des valeurs du"
TRANSLATE TR_HOWCF1 = "Calcul de confiance de multi-source pour"  

Here's an example of the HTML needed to access the French version (autofr.kb) of the auto diagnosis knowledge base:

<HTML>
<HEAD><TITLE>Système expert De Diagnostic D'Automobile</TITLE></HEAD>
<BODY BGCOLOR="#ffee33">
<APPLET CODE="e2glite.e2g.class" archive="e2glite.jar" width=525 height=300>
<PARAM NAME="KBURL" VALUE="autofr.kb">
<PARAM NAME="APPTITLE" VALUE="Conseiller De Diagnostic D'Automobile">
<PARAM NAME="APPSUBTITLE" VALUE="Une démonstration d'eXpertise2Go">
<PARAM NAME="STARTBUTTON" VALUE="Commencez la consultation">
<PARAM NAME="LOADMSG" VALUE="Chargeant la base de connaissance...">
<PARAM NAME="DEBUG" VALUE="false">
Java-capable browser required 
</APPLET>
</BODY>


Recommendations for implementing and debugging a knowledge base

When the "Start the consultation" button is clicked on the e2gLite applet's opening screen, the knowledge base is loaded and syntax checked. If an error is encountered, loading immediately stops and an error number is displayed. If the test is run in the "debug" mode (the DEBUG applet parameter has the value "true") the line containing the error is displayed in the "Knowledge Base Developer's Output" window. As a result, it is most efficient to adhere to the following advice when building a knowledge base:

Some additional debugging suggestions that you might find helpful:

Finally, here is a summary of some commonly encountered knowledge base problems.

Knowledge Base Debugging Suggestions
Symptom Probable Cause Finding the problem
When the Web page containing <APPLET...> tags loads, a grey panel persists where the e2gLite opening screen should appear after the applet is downloaded. The applet cannot be found, or crashes after loading. Look for an error message on browser's status line. Check the Java console for error messages. Make sure the e2glite.jar file is installed in the proper location on the Web server and that the CODE and ARCHIVE attributes in the <APPLET> tag are specified correctly. Browsers running version 1.0.2 of the Java Virtual Machine (the Java console displays the version) cannot load applets from a .jar archive. To support these browsers with e2gLite, use WinEdit or a similar program to unpack the .jar in the same directory. This will create a subdirectory named e2glite and copy all of the class files to that subdirectory. You do not have to change any <APPLET> parameters to allow for operation with these old browsers.
Attribute values for which PROMPTs exist are never requested Different spellings, spacing or punctuation of an attribute name. Run in Debug mode (set the DEBUG <APPLET> parameter to "TRUE"), click "Start the consultation" then click "Analyze KB" in the KNOWLEDGE BASE DEVELOPER'S window. Review the ATTRIBUTE USAGE section of the resulting KNOWLEDGE BASE ANALYSIS for attribute naming problems.
Rules don't fire that should fire as a result of user input. Different spellings, spacing or punctuation of an attribute value. Run in Debug mode (set the DEBUG <APPLET> parameter to "TRUE"), click "Start the consultation" then click "Analyze KB" in the KNOWLEDGE BASE DEVELOPER'S window. Review the VALUE USAGE section of the resulting KNOWLEDGE BASE ANALYSIS for value definition problems.
In the final explanation of conclusions, some rules don't seem to have used all of the known facts in their explanation even though these attributes are in the premise. Could be normal when premise clauses connected by OR Once a rule has fired, it will not be examined again by the inference engine. When premise clauses are OR'd the first true premise clause fires the rule.

[Index][Module 1][Module 2][Module 3][Module 4][Module 5][Module 6][Module 8][Reference][e2gSwing Ref]


Copyright © 2001 - 2009 by eXpertise2Go.com. All rights reserved.
webmaster@expertise2go.com