What are some other things we can do with KNeighborsClassifier?

Question

In the context of this exercise, what are some other things we can do with KNeighborsClassifier?

Answer

With the KNeighborsClassifier function, you have the option to set a few parameters which can change how the model will work, as well as access to methods that can perform useful tasks.

One parameter is the weights, which you can change to determine how each data point is weighted. You can set this parameter to “uniform”, which is the default value, or “distance”, which uses the inverse of each points’ distances so that close neighbors have more impact than farther neighbors.

Another parameter you can set is the algorithm parameter, which will determine what algorithm is used to compute the nearest neighbors. The values include ball_tree, kd_tree, brute, or auto.

The KNeighborsClassifier function also provides a kneighbors() method, which finds all the K-neighbors for given points and returns the indices and distances to the neighbors.

To see a full list of what the function provides, feel free to check out the official documentation.

3 Likes

Hello,
Can you please share the movie_dataset, and labels files or link to download them?

Do you have to normalize the data before classifier.fit() ?

2 Likes

I’ll post a link to the official documentation:
https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html

Yes, to avoid the issue described during the lesson (one big variable overtaking a smaller one).
In the exercise, the data is already normalized though so no need to do it yourself.

1 Like

How is data normalized when it’s not part of a full set? In the previous lessons we normalized data using the min and max values of a full data set. If we have a movie not in the movie set that we want to predict, how do we normalize it? How do you normalize just one point?