Example dataset for k-Nearest Neighbors?

What is an example of a dataset to be used with the k-Nearest Neighbors algorithm?

I understand the concept, but I'm not sure what data will be used for x, y coordinates.

Can I give an example of a data set (with x, y coordinates) for the nearest-neighbor-k algorithm ?

+3
source share
2 answers

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 // the 1st closest point to q 4 4 // the 2nd closest point to q 3 3 // the 3rd closest point to q 
+3
source

You do not understand the concept.

k-NN not limited to datasets with only 2-dimensional points (with x and y coordinates).

Any data set can be used with k-NN , regardless of the number of functions, and you can use many different distance metrics (even those that are not technically reliable metrics).

+1
source

Source: https://habr.com/ru/post/969604/


All Articles