Gain clarity on the k-nearest neighbors machine learning algorithm, a supervised model that classifies data points based on proximity to existing data. Learn how this method differs from regression by examining examples such as height, weight, and flower classification.
Key Insights
- The k-nearest neighbors (KNN) algorithm is supervised machine learning that classifies data points by referencing the closest known data points rather than performing regression calculations.
- KNN classification can be applied in practical contexts, such as categorizing animals based on height and weight or distinguishing flowers in standard machine learning datasets.
- The article outlines initial setup instructions, including importing necessary libraries, initializing the KNN classifier model, and configuring Google Drive integration for data access.
Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.
Here in part three, we're going to be working on the k-nearest neighbors machine learning algorithm. A k-nearest neighbors is a supervised machine learning algorithm for classifying data points based on, hey, what is the value of the closest existing points? So it learns in a different way than the original ones. We did the regressions.
KNN is not a regression. KNN looks instead at its memory of what data points it's seen. Right? Again, we give it, hey, this data point is this value.
This data point is this value. And we can plot all kinds of things with that. For example, height and weight.
We could plot X against Y and get a lot of data points of height and weight, maybe of animals. And be able to classify, okay, this little height and weight area over here seems to be dogs. And this one over here seems to be cats.
We're going to look at some data next in the second part of part three. And we're going to look at some flower data and classify flowers in a classic machine learning dataset. But for now, we're going to explore just the concept of k-nearest neighbor and try to visualize it and try to get a sense of what it's doing.
All right. So very first thing, let's make sure we've got all of our ducks in a row regarding getting everything imported. So combined a couple of things here.
But this is our basic data science imports, including our Jupyter Notebook ability to display images. Here we have our k-nearest neighbors classifier, our model. And we've also set up Google Drive.
So run that. And then as is typical, the base URL for any files we need to look at. Execute that.
And we can also execute this and start talking about k and n. All right. We'll talk about this image and what it means in just a moment.