



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




The Na¨ıve Bayes classifier approximates the joint probability p(x, y) (by estimating p(xi|y) and p(y) and assuming the Na¨ıve Bayes conditional independence) and uses the Bayes rule to calculate p(y|x). It then picks the most likely y as the classification label. Please implement the Na¨ıve Bayes classifier. You should make use of the smoothing technique to avoid the problem of zero probability.
In short, your learner should, given the training data:
pˆ(xi = k|y = v) =
#samples{xi = k, y = v} + l #samples{y = v} + ml
and pˆ(y = v) =
#samples{y = v} + l #samples + ml
You can choose l = 1. Please refer to the next problem for the farmat of the input data file. You can assume that the features are binary, and that the class label is binary, in which case m = 2.
Your classifier should, for each data point in the testing data:
∏n i=1 ˆp(xi|y^ = 1)) ˆp(y^ = 1) (
∏n i=1 ˆp(xi|y^ = 0)) ˆp(y^ = 0)
In your report please include
In your tarball please include
The training and testing data sets will be available on the class website. The data set will be of the following form:
and p(y = 1|x) =
exp(w 0 +
∑n i=1 wixi) 1 + exp(w 0 +
∑n i=1 wixi)
Taking the log of the ratio of the two, the classification rule assigns label 1 if w 0 +
∑n i=1 wixi^ >^ 0, and assigns label 0 otherwise. The update rule for w for the gradient ascent method is
wi ← wi + η
l
xli
yl^ − pˆ(yl^ = 1|x, w)
where the superscript l denotes the lth training example, the subscript i denotes the index of the feature (and the weight), η is a small constant, and ˆp is the logistic regression prediction given by (1) and (2). Please refer to Mitchell’s new book chapter for derivation details. Your learner should, given the training data:
Note that if you add one addition feature x 0 = 1 to every example, w 0 can be handled elegantly. Your classifier should, for each data point in the testing data:
∑n i=1 wixi.
In your report please include
In your tarball please include
In your report please include
In your tarball please include
In your report please compare and discuss your findings given by the two classification approaches, including at least, but not limited to, how each approach performs given different sizes of training sets, how the testing accuracy changes given larger training sets, etc.