KNN clustering
We've got two files we want to look at. The first is the source code in the packtml Python package. Second, we're going to look an example of the KNN applied to the iris dataset. Let's go ahead and jump over to PyCharm, where there are two files open. Inside of the clustering submodule, we have the knn.py file open. This is where we're going to find the KNN class and all the implementation details. Then in the examples directory, in the clustering subdirectory, we have the example_knn_classifier.py file open as well. We'll walk through that after we've gone through the implementation details.
Now, regarding other libraries, we're going to use scikit-learn's utils to validate the X, y, and classification targets. However, we're ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access