Docsity

CS440 Assignment 3: Probability Inference using Bayesian Networks in Clue Game - Prof. Bru, Assignments of Computer Science

Toggle sidebar
bg1
CS440: Introduction to Artificial Intelligence
Fall 2008
Programming Assignment #3: Clue as a Bayesian Net
Due Thursday, Dec. 11th, at noon.
Introduction
In the previous programming assignment, you wrote a resolution theorem prover for the child’s
game of Clue. But of course, Clue is a game; everything is either true or false. In real life, there is
uncertainty. So in this assignment we will use the game of Clue as a domain, but this time the
goal is to infer the probability of an even given a set of evidence. The method of inference should
be variable elimination over a (small) Bayesian net.
The Problem
In the game of Clue, there are three explicit random variables: Person (Mustard, Scarlett, Plum,
Green, White, Peacock), Weapon (Wrench, Candlestick, Rope, Knife, Revolver, Pipe), and Room
(Hall, Lounge, Dining, Kitchen, Ballroom, Conservatory, Billiard, Library, Study). Looking at
crime statistics (well, pretending to) we have also determined that we need three implicit random
variables: Gender (M, F), Cook (T, F) and Military(T, F). The motivation for the additional
variables is as follows: women stereotypically prefer certain types of weapons (e.g. knives), while
men prefer others (e.g. revolvers, pipes and wrenches). Cooks are more likely to be in the kitchen
and to have access to knives. (From her outfit, we infer that Mrs. White is more likely than the
others to be a cook, although academics also tend to like to cook, so Prof. Plum is slightly more
likely to be a cook than the others.) Current and former members of the military are trained to use
guns. (Note that we don’t know if Col. Mustard was in the military or if his moniker is just an
affect, but we will infer that it is more likely.) The Bayesian net that relates these six variables is
given in Figure 1, below. The conditional probability tables are also given below.
Your job is to write a program that takes in evidence and a query variable assignment, and prints
out the probability of the query variable assignment given the evidence. The evidence consists of
assignments for any subset of variables (including the empty set and the full set). The query
variable assignment is the target that you are calculating the probability of. For example, you
might get the following input:
Cook = F
Weapon = Knife
Query = Room = Library
Your program should then print out probability that the murder was committed in the library,
given that the murderer was a cook and the murder weapon was a knife.
Input
Your program should take the name of an input file as its only argument. The file will be an input
file. The last line of the file will contain a query variable. Any preceding lines will contain
evidence variables. An evidence variable line will be of the form “Variable = Value”, as in the
example above. Note that the variable names, equal signs and values are separated by a space,
and that there is only one variable per line. The values for Gender are M and F. The values for
pf3
pf4

Partial preview of the text

Download CS440 Assignment 3: Probability Inference using Bayesian Networks in Clue Game - Prof. Bru and more Assignments Computer Science in PDF only on Docsity!

CS440: Introduction to Artificial Intelligence

Fall 2008

Programming Assignment #3: Clue as a Bayesian Net

Due Thursday, Dec. 11

th

, at noon.

Introduction

In the previous programming assignment, you wrote a resolution theorem prover for the child’s

game of Clue. But of course, Clue is a game; everything is either true or false. In real life, there is

uncertainty. So in this assignment we will use the game of Clue as a domain, but this time the

goal is to infer the probability of an even given a set of evidence. The method of inference should

be variable elimination over a (small) Bayesian net.

The Problem

In the game of Clue, there are three explicit random variables: Person (Mustard, Scarlett, Plum,

Green, White, Peacock), Weapon (Wrench, Candlestick, Rope, Knife, Revolver, Pipe), and Room

(Hall, Lounge, Dining, Kitchen, Ballroom, Conservatory, Billiard, Library, Study). Looking at

crime statistics (well, pretending to) we have also determined that we need three implicit random

variables: Gender (M, F), Cook (T, F) and Military(T, F). The motivation for the additional

variables is as follows: women stereotypically prefer certain types of weapons (e.g. knives), while

men prefer others (e.g. revolvers, pipes and wrenches). Cooks are more likely to be in the kitchen

and to have access to knives. (From her outfit, we infer that Mrs. White is more likely than the

others to be a cook, although academics also tend to like to cook, so Prof. Plum is slightly more

likely to be a cook than the others.) Current and former members of the military are trained to use

guns. (Note that we don’t know if Col. Mustard was in the military or if his moniker is just an

affect, but we will infer that it is more likely.) The Bayesian net that relates these six variables is

given in Figure 1, below. The conditional probability tables are also given below.

Your job is to write a program that takes in evidence and a query variable assignment, and prints

out the probability of the query variable assignment given the evidence. The evidence consists of

assignments for any subset of variables (including the empty set and the full set). The query

variable assignment is the target that you are calculating the probability of. For example, you

might get the following input:

Cook = F

Weapon = Knife

Query = Room = Library

Your program should then print out probability that the murder was committed in the library,

given that the murderer was a cook and the murder weapon was a knife.

Input

Your program should take the name of an input file as its only argument. The file will be an input

file. The last line of the file will contain a query variable. Any preceding lines will contain

evidence variables. An evidence variable line will be of the form “Variable = Value”, as in the

example above. Note that the variable names, equal signs and values are separated by a space,

and that there is only one variable per line. The values for Gender are M and F. The values for

Cook and Military are T and F. The values for Person, Weapon and Room are the same as in the

last assignment. The last line contains the query variable, which is of the form “Query = Variable

= Value”, as in the example above.

Output

Your program should write a single number (between 0 and 1) to standard out. This variable

should be the probability of the query assignment given the evidence provided.

Late Policy

Assignments are due when they are due; late assignments are not accepted. I know I said this last

time, and then gave the class an extension (you seemed to need it). This time there can be no

extension, because by university policy I cannot accept assignments after the end of classes.

There is a departmental exception for “unforeseeable circumstances”. Examples include medical

emergencies, family tragedies, fires, etc. If such an unforeseeable circumstance happens to you,

please talk to the instructor. We will work with you on a case-by-case basis.

As always….

All work must be your own. You may not copy code from the internet, your colleagues or anyone

else. See the department cheating policy.

Conditional Probabilities

Here are the conditional probability tables for your Bayesian network:

Gender M F 0.6 0.

Person Gender P(Scarlett) P(White) P(Peacock) P(Mustard) P(Green) P(Plum) M 0.0 0.0 0.0 0.333 0.333 0. F 0.333 0.333 0.333 0.0 0.0 0.

Cook Person P(T) P(F) Scarlet 0.5 0. White 0.9 0. Peacock 0.5 0. Mustard 0.5 0. Green 0.5 0. Plum 0.6 0.