knn

K Nearest Neighbour Algorithm doubt

Hi, I am new to Artificial Intelligence. I understand K nearest neighbour algorithm and how to implement it. However, how do you calculate the distance or weight of things that aren't on a scale? For example, distance of age can be easily calculated, but how do you calculate how near is red to blue? Maybe colours is a bad example becaus...

minimal graph on spatial points

I have a set of 3 dimensional points. I want a quick query of the k nearest neighbours of any of these points. I know that a usual way of doing this is oct-tree, however I think that with the below described data structure the query would be much faster. I want a minimal graph on the points as vertices, which have the following proper...

Dynamic closest elements

Hi, I have a 2D surface ( Grid ) with 50 elements at different locations. I need to decide which are the 10 closest elements to a given point. In addition, the given point is constantly moving and i need to do the calculation on each movement. I know I can calculate the Euclidean distance to each point on each movement, but I want a f...

Is k-d tree efficient for kNN search. k nearest neighbors search

I have to implement k nearest neighbors search for 10 dimensional data in kd-tree. But problem is that my algorithm is very fast for k=1, but as much as 2000x slower for k>1 (k=2,5,10,20,100) Is this normal for kd trees, or am I doing something worng? ...

Efficient method for finding KNN of all nodes in a KD-Tree

I'm currently attempting to find K Nearest Neighbor of all nodes of a balanced KD-Tree (with K=2). My implementation is a variation of the code from the Wikipedia article and it's decently fast to find KNN of any node O(log N). The problem lies with the fact that I need to find KNN of each node. Coming up with about O(N log N) if I ...

Is it possible to find the KNN for a node that is *IN* the KD-tree?

Hi there, Trying to create a KNN search using a KD-tree. I can form the KD-tree fine (or at least, I believe I can!). My problem is that I am searching to find the closest 2 neighbours to every point in a list of points. So, is there a method to find the K nearest neighbours to a point using a KD tree even if the point is actually IN ...

Using Nearest Neighbour Algorithm for image pattern recognition

So I want to be able to recognise patterns in images (such as a number 4), I have been reading about different algorithms and I would really like to use the Nearest Neighbour algorithm, it looks simple and I do understand it based on this tutorial: http://people.revoledu.com/kardi/tutorial/KNN/KNN_Numerical-example.html Problem is, altho...