Description
CptS 440/540 Artificial Intelligence
Homework 10
1. Consider the table of data below, which contains 11 examples of the class value BuyJersey based on the features Weather, Uniform and Win. Suppose we want to classify the new instance <Weather=cloudy, Uniform=gray, Win=yes> using the Naïve Bayes learning method. Compute the following. Show your work. Note: use the “add 1 / |values|” method only if the original P(feature | class) = 0.
Weather Uniform Win BuyJersey
clear crimson yes yes
clear crimson no yes
clear gray yes yes
clear gray no no
cloudy crimson yes yes
cloudy crimson no yes
cloudy gray no no
rainy crimson yes yes
rainy crimson no yes
rainy gray yes no
rainy gray no no
a. Compute the prior probabilities P(BuyJersey=yes) and P(BuyJersey=no).
b. Compute P(Weather | BuyJersey) for all values of Weather Î {clear, cloudy, rainy} and BuyJersey Î {yes, no}.
c. Compute P(Uniform | BuyJersey) for all values of Uniform Î {crimson, gray} and BuyJersey Î {yes, no}.
d. Compute P(Win | BuyJersey) for all values of Win Î {yes, no} and BuyJersey Î {yes, no}.
e. Compute P(BuyJersey=yes | Weather=cloudy, Uniform=gray, Win=yes) and P(BuyJersey =no | Weather=cloudy, Uniform=gray, Win=yes).
f. Which class would Naïve Bayes choose for the new instance?
1
2. Perceptron. Train a perceptron on the 11 examples in the above table and then use the perceptron to classify the new instance. Specifically,
a. Translate the examples (including the BuyJersey class value) according to the mapping: clear 0, cloudy 1, rainy 2, crimson 0, gray 1, no 0, yes 1. Show a new table of examples using this mapping.
b. Translate the new instance according to the mapping in part (a). Show the resulting instance. How would the perceptron below (before any training) classify the new instance? Show your work.
c. Train the perceptron below using one pass through the 11 examples by updating the weights according to the perceptron learning rule (slide 34 of Learning lecture). Assume the initial weights are all equal to 1.0, and h = 0.5. Consider each example in the order presented in the table above and show the weight updates for each incorrectlyclassified example. Show your work. Hint: There should be three weight updates.
d. How would the trained perceptron from part (c) classify the new instance <Weather=cloudy, Uniform=gray, Win=yes>? Show your work.
3. CptS 540 Students Only: Put the 11 training examples from the initial table above (used in Problem 1) into an ARFF file suitable for input to WEKA. Follow the procedure below to run the Naive Bayes classifier.
a. Download and install WEKA from www.cs.waikato.ac.nz/ml/weka/downloading.html.
b. Start WEKA and choose the Explorer mode.
c. Under the Preprocess tab, choose “Open file…” and load your ARFF file.
d. Under the Classify tab, choose the “bayes®NaiveBayes” classifier.
e. Under Test options, choose “Use training set”.
f. Click Start to run the classifier on your data.
g. Include your ARFF file and WEKA’s output in your submission.
4. Extra Credit (5 points). Continue training the perceptron in 2(c) until it correctly classifies all 11 examples. Show the final perceptron weights. Hint: The perceptron should correctly classify all 11 examples on the 6th pass through the examples (where 2(c) is the 1st pass).
2
Reviews
There are no reviews yet.