NN search is carried out in a simple way:
- You have a database of elements (here you have 2 dimensional points, with
x and y coordinates). - A
query , which is the same type of database element, thus a 2D point in your case. - The goal is to find what is the most identical
query point in the database.
There are many algorithms that allow us not to search the entire database, but to search only what is of interest to query , thereby effectively responding to query .
Example:
The database has 6 2D points: (so you are referencing a datatset )
0 0 1 1 2 2 3 3 4 4 5 5
A query A 2D point arrives:
q = (9, 9)
The answer is the closest point to q , which in this example is (5, 5) .
In the search, the kNN query asks for the k most identical database elements, which in our example are the k nearest database points presented above to the q query point.
So, for k = 3 , for example, the answer should be:
5 5
source share