nearest-neighbor

How does space partitioning algorithm for finding nearest neighbors work?

三世轮回 提交于 2019-12-05 09:14:24
For finding the nearest neighbor, Space Partitioning is one of the algorithms. How does it work? Suppose I have a 2D set of points (x and y coordinates), and I am given a point (a,b). How would this algorithm find out the nearest neighbor? Spacial partitioning is actually a family of closely related algorithms that partition space so that applications can process the points or polygons easier. I reckon there are many ways to solve your problem. I don't know how complex you are willing to build your solution. A simple way would probably to build a binary tree cutting the space into 2. All the

Postgresql k-nearest neighbor (KNN) on multidimensional cube

谁说胖子不能爱 提交于 2019-12-05 07:11:26
I have a cube that has 8 dimensions. I want to do nearest neighbor matching. I'm totally new to postgresql. I read that 9.1 supports nearest neighbor matching on multidimensions. I'd really appreciate if someone could give a complete example: How to create a table with the 8D cube ? Sample Insert Lookup - exact matching Lookup - nearest neighbor matching Sample Data: For simplicity sake, we can assume that all the values range from 0-100. Point1: (1,1,1,1, 1,1,1,1) Point2: (2,2,2,2, 2,2,2,2) Look up value: (1,1,1,1, 1,1,1,2) This should match against Point1 and not Point2. Refs: What's_new_in

K-Nearest Neighbors and MySql Geographical Index

时间秒杀一切 提交于 2019-12-05 05:34:34
问题 I have a set of geo-tagged pictures in mySql database. You can consider my Pictures table to be: create table `Pictures` ( location Point NOT NULL, timeCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, SPATIAL INDEX(location) )ENGINE= MyISAM DEFAULT CHARSET=utf8; I intend to perform a K-Nearest Neighbor algorithm based on the location of the pictures. Say, if K=10, select the 10 pictures which are geographically closest to the user location. I appreciate your suggestions. 回答1: Have a look

Implementing KNN with different distance metrics using R

只谈情不闲聊 提交于 2019-12-05 05:21:41
问题 I am working on a dataset in order to compare the effect of different distance metrics. I am using the KNN algorithm. The KNN algorithm in R uses the Euclidian distance by default. So I wrote my own one. I would like to find the number of correct class label matches between the nearest neighbor and target. I have prepared the data at first. Then I called the data ( wdbc_n ), I chose K=1. I have used Euclidian distance as a test. library(philentropy) knn <- function(xmat, k,method){ n <- nrow

R function to calculate nearest neighbor distance given [inconsistent] constraint?

笑着哭i 提交于 2019-12-04 19:11:51
I have data consisting of tree growth measurements (diameter and height) for trees at known X & Y coordinates. I'd like to determine the distance to each tree's nearest neighbor of equal or greater size . I've seen other SE questions asking about nearest neighbor calculations (e.g., see here , here , here , here , etc.), but none specify constraints on the nearest neighbor to be searched. Is there a function (or other work around) that would allow me to determine the distance of a point's nearest neighbor given that nearest point meets some criteria (e.g., must be equal to or greater in size

PCL kd-tree implementation extremely slow

為{幸葍}努か 提交于 2019-12-04 12:44:48
I am using Point Cloud Library (PCL) based C++ implementation of kd-tree nearest neighbour(NN) searching. The data set contains about 2.2 million points. I am searching NN points for every other point. The search radius is set at 2.0. To fully compute that, it takes about 12 hours! I am using windows 64 bit machine with 4GB RAM. Is it very common for kd-tree searching? I wonder if there is any other c++ library for 3D point cloud data, which is faster. I heard about ANN C++ library & CGAL, but not sure how fast these are. In short: You can only be sure if you run yourself the time measurements

rethinkdb with filter and getNearest commands

徘徊边缘 提交于 2019-12-04 11:44:07
How can execute getNearest query about the result of other command, for example a filter command? var point = r.point(-122.422876,37.777128); r.db('test').table('users'). filter({tags : 'tag'}). getNearest(point, {index: 'geodata', maxResults: 30, unit :'km'}) I have a 'users' table: [ {id: 1, tags : ['music', 'cups'], geodata: r.point()} {id: 2, tags: ['music', 'play'], geodata: r.point()} ] First I want to filter by 'tags' field and then return the nearest. The query that I have specified is incorrect, return the follow error: " RqlRuntimeError: Expected type TABLE but found SELECTION " The

Nearest Neighbor Search in Python without k-d tree

别来无恙 提交于 2019-12-04 10:33:45
问题 I'm beginning to learn Python coming from a C++ background. What I am looking for is a quick and easy way to find the closest (nearest neighbor) of some multidimensional query point in an 2D (numpy) array of multidimensional points (also numpy arrays). I know that scipy has a k-d tree, but I don't think this is what I want. First of all, I will be changing the values of the multidimensional points in the 2D array. Secondly, the position (coordinates) of each point in the 2D array matters as I

Finding near neighbors

谁说胖子不能爱 提交于 2019-12-04 10:12:36
问题 I need to find "near" neighbors among a set of points. There are 10 points in the above image. Red lines are edges from the Delaunay Triangulation, black stars mark the mid-lines of the edges, blue lines are the Voronoi tesselation. Point 1 has three "near" neighbors, i.e. 4, 6, and 7, but not 2 and 3, who are almost in line with the edge 1-7, but much further away. What is a good way to identify the near neighbors (or "good" edges)? Looking at the figure, it seems to me that either selecting

How to bucket locality-sensitive hashes?

会有一股神秘感。 提交于 2019-12-04 08:34:10
I already have the algorithm to produce locality-sensitive hashes, but how should I bucket them to take advantage of their characteristics(i.e. similar elements have near hashes(with the hamming distance))? In the matlab code I found they simply create a distance matrix between the hashes of the points to search and the hashes of the points in the database, to simplify the code,while referencing a so called Charikar method for an actually good implementation of the search method. I tried to search for that, but I'm not sure how to apply to my case any of the methods I found(like the multi