Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use R code to complete the following 4 points] Consider again the zip code digits data. And we will use the Eucleadian distance. We want

Use R code to complete the following

image text in transcribed

4 points] Consider again the zip code digits data. And we will use the Eucleadian distance. We want to predict the digit of the 4th observation in the testing dataset library (ElemStatLearn) train.x zip.traint, -1] train.y -as.factor(zip.train[, 1]) test.x.one zip.test 14,-1 Do the following steps. Note that you cannot use any built-in kNN function for this entire question. For step1),you cannot use any for-loops. As a hint, you may consider using sweep and rowSums, while other functions can also get the job done. 1. Using covariates test.x.one find the indices of all 15 nearest neighbors in the training data. 2. Find the most frequent digit among these 15 observations. Is this the true digit of this testing data? 3. How about changing the value of k? Can we get a correct prediction? Apply steps 1 and 2 to the first 100 observations in the testing data, with k ranging from 1 to 20. Which k seems to perform the best? Use evidence to support your answer. 4 points] Consider again the zip code digits data. And we will use the Eucleadian distance. We want to predict the digit of the 4th observation in the testing dataset library (ElemStatLearn) train.x zip.traint, -1] train.y -as.factor(zip.train[, 1]) test.x.one zip.test 14,-1 Do the following steps. Note that you cannot use any built-in kNN function for this entire question. For step1),you cannot use any for-loops. As a hint, you may consider using sweep and rowSums, while other functions can also get the job done. 1. Using covariates test.x.one find the indices of all 15 nearest neighbors in the training data. 2. Find the most frequent digit among these 15 observations. Is this the true digit of this testing data? 3. How about changing the value of k? Can we get a correct prediction? Apply steps 1 and 2 to the first 100 observations in the testing data, with k ranging from 1 to 20. Which k seems to perform the best? Use evidence to support your

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions