From the course: Introduction to Data Science

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Implementing k-Nearest Neighbors

Implementing k-Nearest Neighbors

From the course: Introduction to Data Science

Implementing k-Nearest Neighbors

In this lesson, I'll go over an example of implementing the K-Nearest Neighbors or K-NN algorithm. Let's say you have a data set that was collected to help doctors diagnose chronic kidney disease or CKD. Each row in the data set represents a patient who was treated in the past and whose diagnosis is known. For each patient, you have a set of measurements from a blood test. Your goal is to develop a way to classify future patients, as has CKD or doesn't have CKD based on their blood test results. I've opened up the exercise file for this lesson. Feel free to open the exercise file on your end as well to follow along. In the first code cell, I started by importing all the python libraries that I'll need. This includes imports from Pandas, Matplotlib, Seaborn and Sklearn. Sklearn is another powerful library for data science. It contains many useful methods for implementing machine learning algorithms in Python. You can learn more about it using the link in the resource file. Next, I…

Contents