Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer all parts of this question and show all your workings, including all the R codes and graphs. 2. (8 marks) In this question,
Please answer all parts of this question and show all your workings, including all the R codes and graphs.
2. (8 marks) In this question, you will fit kNN regression models to the Auto data set to predict Y = mpg using X = horsepower. This data has been divided into training and testing sets: AutoTrain. csv and AutoTest. csv (download these sets from LEARN). The kNN () R function on Learn should be used to answer this question (you need to run the kNN code before calling the function). (a) Without any programming find the value of the training MSE for the kNN when k = 1 (justify your answer). Argue which is larger, the training MSE or the testing MSE, again for the case k = 1. (b) Perform kNN regression with k = 2, 5, 10, 20, 30, 50 and 100, (learning from the training data) and compute the training and testing MSE for each value of k. (c) Which value of k performed best? Explain. (d) Plot the training data, testing data and the best kNN model in the same figure. ( The points () function is useful to plot the kNN model because it is discontinuous.) (e) Describe the bias-variance trade-off for kNN regressionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started