Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have just learned KNN in R, I don't understand how to coding with this. Can anyone give an answer and explain that? Thank you.

image text in transcribedI have just learned KNN in R, I don't understand how to coding with this. Can anyone give an answer and explain that? Thank you.

##### Distance Matrix. How does euclidean distance work on numeric data? The KNN algorithm calculates the distance between all rows of observations in a data set. This produces a distance matrix. The matrix can be used to "look up" the distance between one row of data and another row. Once we have a distance metric, euclidean in our case, we can calculate a distance matrix of distances between all data points. Then, for a new point, we can calculate its distance to all other points, find the K nearest points, and assign the most common label to the new point. The following is a small example of how KNN works, with age and income as the variables, and credit as the label (Refer to the text, ch3, p78 as this code is very similar). Q1(2pts): Create a data frame using the function data.frame, called cred.data, that contains these vectors: age 69,66,49,49,58,44 income = : 3,57,79,17,26,71 credit 'low', 'low', 'low', 'low','high','high' Note: you can use the data.frame method to do this easily. '{r} cred data

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 Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

6. Testing equipment that will be used in instruction.

Answered: 1 week ago