From the course: Supervised Learning Essential Training

Unlock the full course today

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

What's the big deal about k

What's the big deal about k - Python Tutorial

From the course: Supervised Learning Essential Training

Start my 1-month free trial

What's the big deal about k

- [Instructor] Finding the correct value for k is the most significant step in creating the k-nearest neighbors algorithm. If k is one, then the algorithm will only use its singular nearest neighbor to make predictions. If k is 10, then the algorithm will use an instance's 10 nearest neighbors to make predictions. It's important to plot and gain a visual intuition for what values for k would make sense. To find a good value for k, we run the KNN algorithm several times with several different values for k each time. Then we choose the value for k that reduces the number of errors while still accurately making predictions given unseen data. As we adjust our k value, it's important to keep some concepts in mind. When we reduce k to one, it's possible that our predictions will be inaccurate and unstable. It's a best practice to set k to an odd number, so we can take a majority vote among labels. For classification problems,…

Contents