UPDATE 5 October 2013: Due to changes in the latest Java plugin, eXpertise2Go cannot be used in the way described here. However, I have successfully used a similar system, CLIPS, to create expert systems and use the examples, tasks, and lesson ideas described here. Please see Creating an Expert System with CLIPS.
Yesterday’s blog post contained several examples of expert systems for ITGS students and teachers. In today’s post, we’re going to create our own simple expert system. The software we are going to use for this is called Expertise2Go, which is free to download. You can also download the software and the files for this tutorial (including this blog post as a classroom handout) from the Artificial Intelligence section of the ITGS textbook site.
In this tutorial, we are going to create the user interface and the knowledge base for a very simple expert system: one that determines the title for a person from the options: Mr, Mrs, or Miss. (I won’t get into the Ms debate right now). The diagram below shows the knowledge in this domain.
The GOAL command is used to specify what the expert system is trying to achieve. GOAL is followed by a variable name. In this example we are trying to determine a person’s correct title (Mr, Mrs, Miss), so our goal is:GOAL [title]
(the square brackets are required around all variable names)
The User Interface
The PROMPT command is used to get input from the user. Whatever the user types will be stored in the variable whose name is written after the PROMPT command.
There are different types of PROMPT. A MultChoice prompt provides the user with a list of options from which to choose. The next line contains the prompt or question for the user (in quotes), and the choices are written on the lines after that (again, in quotes). For example, to prompt a user whether they are male or female, and store their answer in a variable called [gender], we would use the code:
PROMPT [gender] MultChoice
“What is your gender?”
The Knowledge Base
The knowledge base consists of a series of RULEs. Each rule has a name which follows the RULE statement and is written in square brackets. Like variables, rules should be given sensible names to make them memorable and clear.
Usually rules test the value of one or more variables and make a decision based on that. In our example, to determine whether a person’s correct title is “Mr”, we need to know if they are male. A simple rule to do this looks like this:
RULE [1. Mr]
If [gender] = “Male”
THEN [title] = “Mr”
The If [gender] clause of this rule will automatically call the PROMPT gender above to ask the user their gender. The user’s answer will be stored in the gender variable and then compared to “Male”. If it matches, the variable title (notice how we used title in our GOAL earlier) is assigned the value “Mr” and the program will the end. If it does not match, the program moves onto the next rule.
Some rules must consider more than one variable. For example, if the user is female we must then also consider the marital status to determine the title. We need two rules to achieve this:
RULE [2. Mrs]
If [gender] = “Female” and
[marital status] = “Married”
Then [title] = “Mrs”
RULE [3. Miss]
If [gender] = “Female” and
[marital status] = “Single”
Then [title] = “Miss”
(Both of these rules assume we have written another PROMPT in our user interface which asks for the user’s marital status and stored it in a variable called “marital status”)
When the knowledge base rules and the user interface prompts are completed, the expert system can be running using the Run-expert-system.html file in the folder you downloaded.
[Note: Expertise2Go requires the RULE statements to appear in the text file before the PROMPT statements.]