4.5

4.5 | 4 ratings Rate this file 258 downloads (last 30 days) File Size: 2.47 KB File ID: #19345

Efficient K-Nearest Neighbor Search using JIT

by Yi Cao

 

27 Mar 2008 (Updated 07 Jul 2008)

Code covered by BSD License  

A small but efficient tool to perform KNN search

Download Now | Watch this File

File Information
Description

This is a small but efficient tool to perform K-nearest neighbor search, which has wide Science and Engineering applications, such as pattern recognition, data mining and signal processing.

The code was initially implemented through vectorization. After discussions with John D'Errico, I realized that my algorithm will suffer numerical accurancy problem for data with large values. Then, after trying several approaches, I found simple loops with JIT acceleration is the most efficient solution. Now, the performance of the code is comparable with kd-tree even the latter is coded in a mex file.

The code is very simple, hence is also suitable for beginner to learn knn search.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
distance.m, KD Tree Nearest Neighbor and Range Search, NEARESTPOINT, nearestneighbour.m, IPDM: Inter-Point Distance Matrix

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
20 Dec 2008 Luigi Giaccari

I think someone, maybe not the author, is faking the download number.
My opinion is that this is a very usefull routine, very well commented and totally m-coded.
The performances of course can not be the ones declared in the presentation. The algorithm it is just a brute search can only be competitive against kd-tree data structure for a small number of search and reference points.
For KNN search is used the sort function to find K-neighbours, and this is a very brute algorithm. I Know this the fastest m-code way to find KNN, but it is clear
that kd-trees will overcome this algorithm for very small models.

05 Apr 2009 V. Poor  
Please login to add a comment or rating.
Updates
07 Jul 2008

fix a bug

Tag Activity for this File
Tag Applied By Date/Time
statistics Yi Cao 22 Oct 2008 09:55:26
probability Yi Cao 22 Oct 2008 09:55:26
knearest neighbors Yi Cao 22 Oct 2008 09:55:26
nearest neighbor search Yi Cao 22 Oct 2008 09:55:26
delaunay Yi Cao 22 Oct 2008 09:55:26
kdtree Yi Cao 22 Oct 2008 09:55:26
jit Yi Cao 22 Oct 2008 09:55:26
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com