5
$\begingroup$

I was taking the tutorial of making Recommendation system , there I read that Nearest Neighbor is different from KNN classifier . Could anyone explain that what is Nearest Neighbor and how it is different between KNN ?

$\endgroup$
4
  • 1
    $\begingroup$ Can you link to that tutorial so that we can understand the context? $\endgroup$
    – noe
    Commented Apr 26, 2021 at 10:49
  • $\begingroup$ I saw on the youtube tutorial and there he says only that Nearest Neighbor is unsupervised learning $\endgroup$
    – Hamza
    Commented Apr 26, 2021 at 10:57
  • $\begingroup$ Presumably, the difference is K-1 neighbors. $\endgroup$
    – Ray
    Commented Apr 26, 2021 at 20:43
  • $\begingroup$ Nearest neighbor usually works by creating vectors for objects and then comparing them. I don't know how knn works under the hood, but if that works the same way, then they are the same. Only knn looks for more than one neighbor. $\endgroup$
    – RFAI
    Commented Nov 2, 2022 at 0:07

2 Answers 2

7
$\begingroup$

Not really sure about it, but KNN means K-Nearest Neighbors to me, so both are the same. The K just corresponds to the number of nearest neighbours you take into account when classifying.

Maybe what you call Nearest Neighbor is a KNN with K = 1.

$\endgroup$
1
  • 1
    $\begingroup$ That's it. I believe Neirest Neighbors is the general method name (idea of looking your neighbors to see what you are) while KNN stands for the specific algorithm : If you make a 10 Nearest Neighbor, algorithm will check the 10 known closer neighbors and make a mean / classifying (depending context) $\endgroup$
    – Adept
    Commented Apr 26, 2021 at 12:40
4
$\begingroup$

Scikit wrote in his documantation:

sklearn.neighbors provides functionality for unsupervised and supervised neighbors-based learning methods. Unsupervised nearest neighbors is the foundation of many other learning methods, notably manifold learning and spectral clustering. Supervised neighbors-based learning comes in two flavors: classification for data with discrete labels, and regression for data with continuous labels.

The principle behind nearest neighbor methods is to find a predefined number of training samples closest in distance to the new point, and predict the label from these. The number of samples can be a user-defined constant (k-nearest neighbor learning), or vary based on the local density of points (radius-based neighbor learning). The distance can, in general, be any metric measure: standard Euclidean distance is the most common choice.

You can read more about it here https://scikit-learn.org/stable/modules/neighbors.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.