nearest-neighbor

nearest neighbour search 4D space python fast - vectorization

六眼飞鱼酱① 提交于 2020-08-26 07:10:06
问题 For each observation in X (there are 20) I want to get the k(3) nearest neighbors. How to make this fast to support up to 3 to 4 million rows? Is it possible to speed up the loop iterating over the elements? Maybe via numpy, numba or some kind of vectorization? A naive loop in python: import numpy as np from sklearn.neighbors import KDTree n_points = 20 d_dimensions = 4 k_neighbours = 3 rng = np.random.RandomState(0) X = rng.random_sample((n_points, d_dimensions)) print(X) tree = KDTree(X,

Java implementation of nearest neighbour algorithm for the travelling salesman problem, using dynamic programming [closed]

穿精又带淫゛_ 提交于 2020-08-20 11:10:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 days ago . Improve this question I am trying to use Java to implement the nearest neighbour algorithm for the travelling salesman problem. Before I knew precisely what I was looking for, I asked a similar question here, but received no assistance. I am starting with a matrix table[i][j] ==

Best data structure for high dimensional nearest neighbor search

元气小坏坏 提交于 2020-06-25 05:32:32
问题 I'm actually working on high dimensional data (~50.000-100.000 features) and nearest neighbors search must be performed on it. I know that KD-Trees has poor performance as dimensions grows, and also I've read that in general, all space-partitioning data structures tends to perform exhaustive search with high dimensional data. Additionally, there are two important facts to be considered (ordered by relevance): Precision: The nearest neighbors must be found (not approximations). Speed: The

How to get the nearest neighbor in weka using java

两盒软妹~` 提交于 2020-05-25 01:14:12
问题 I've been trying to use the Ibk nearest neighbor algorithm that goes together with the weka machine learning library. I know how to classify instances, but I want to implement the collaborative filtering feature so I need to actually get the list of actual objects that are nearest to the object of interest. How would I actually do so in weka using its java API? 回答1: How about this one weka.core.neighboursearch.LinearNNSearch knn = new LinearNNSearch( trainingInstances); //do other stuff

Conditional Nearest Neighbor in Python

筅森魡賤 提交于 2020-02-22 04:09:10
问题 I’m trying to do some nearest neighbour type analysis in Python using Pandas/Numpy/Scipy etc. and having tried a few different approaches, I’m stumped. I have is 2 dataframes as follows: df1 Lon1 Lat1 Type 10 10 A 50 50 A 20 20 B df2 Lon2 Lat2 Type Data-1 Data-2 11 11 A Eggs Bacon 51 51 A Nuts Bread 61 61 A Beef Lamb 21 21 B Chips Chicken 31 31 B Sauce Pasta 71 71 B Rice Oats 81 81 B Beans Peas I’m trying to identify the 2 nearest neighbours in df2 (based upon the Lon / Lat values using