From the course: R Essential Training Part 2: Modeling Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Classifying cases with k-nearest neighbors

Classifying cases with k-nearest neighbors

From the course: R Essential Training Part 2: Modeling Data

Start my 1-month free trial

Classifying cases with k-nearest neighbors

- [Instructor] When you're trying to decide how to classify a case, is this a yes or it a no, is it junk mail, is it legitimate mail or what kind of talents does this person have. The best way to do it is to see what the other ones that are similar to it have. This is the idea behind k-nearest neighbors. The way it works is you find a data point that needs to be classified and then you see where it is located in a multidimensional space, where each dimension is variable, and then you simply look at the ones that are closest to it. Maybe you look at three or five or 29 that are closest to it and then you use the categorization that is common among those or if it's a quantitative score, maybe you just average the ones that are around it. So again, it's a matter of looking around you. Doing a sort of social comparison with data to see how you should categorize a data point. To do this, I'm going to load a few packages…

Contents