This preview shows pages 1–2. Sign up to view the full content.
Homework 5
1) Read Chapter 5 (Sections 5.2, 5.3, 5.5 and 5.6).
2) This question deals with In Class Exercise #34.
a) Repeat In Class Exercise #34 for the knearest neighbor classifier for
k=1,2,.
..,10. (We did k=1 in class which is the default). Use R to produce a
single plot showing both the training error and the test error as functions of
the value of k. Provide your R code. Remember that the 61st column is the
response and the other 60 columns are the predictors. Provide a legend on
your plot and label the axes. Include your name in the title of the plot. What
value of k does your plot suggest is optimal with regard to the test error?
b) Repeat part a using the exact same R code. Explain why both the training
errors and the test errors change for even values of k but not for odd values
of k. Hint: Read the help on the knn function if you do not know.
3) This question deals with In Class Exercise #36.
a) Using the abline() function, add some lines to the plot from In Class
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Summer '09
 TAYLOR

Click to edit the document details