473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Fast kNN from python

Hi!

I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.

I haven't looked at the methods in detail but I think I'm looking for
one of the data structures listed on http://en.wikipedia.org/wiki/Metric_trees
(i.e. vp-trees, cover trees, m-trees or bk trees). But I might be
wrong. An approximate kNN would also work.

If there doesn't exist such an implementation yet, any advice on a
library I can wrap myself would also be appreciated.

Thanks!
Janto

PS Before anyone suggests it, I can't use the library at
http://www.cs.umd.edu/~mount/ANN/ as it assumes Minkowski distance
functions.

Aug 14 '07 #1
5 8108
Janto Dreijer wrote:
I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.
Orange? See http://www.ailab.si/orange/ - not sure about speed, but
quite a few parts of it are written in C, and it does kNN.

Tim C
Aug 14 '07 #2
Hello,
I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.
First Google search for "k-Nearest Neighbors python", yielded
http://people.revoledu.com/kardi/tut...resources.html which
pointed to http://biopython.org/DIST/docs/api/p...NN-module.html

HTH,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com

Aug 14 '07 #3
On Aug 14, 6:16 am, Janto Dreijer <jan...@gmail.comwrote:
Hi!

I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.

I haven't looked at the methods in detail but I think I'm looking for
one of the data structures listed onhttp://en.wikipedia.org/wiki/Metric_trees
(i.e. vp-trees, cover trees, m-trees or bk trees). But I might be
wrong. An approximate kNN would also work.

If there doesn't exist such an implementation yet, any advice on a
library I can wrap myself would also be appreciated.

Thanks!
Janto
Have you looked at using Rpy and R? There are probably several knn
implementations that then become accessible to you (although I haven't
checked recently).

Sean
Aug 14 '07 #4
On Aug 14, 8:44 pm, Miki <miki.teb...@gmail.comwrote:
Hello,
I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.

First Google search for "k-Nearest Neighbors python", yieldedhttp://people.revoledu.com/kardi/tutorial/KNN/resources.html which
pointed tohttp://biopython.org/DIST/docs/api/public/Bio.kNN-module.html

HTH,
--
Miki <miki.teb...@gmail.com>http://pythonwise.blogspot.com
Thanks. Indeed, I did see that page. Unfortunately biopython's knn
does a brute force search for the nearest k and is therefore way too
slow.

Janto

Aug 14 '07 #5
On Aug 14, 9:27 pm, Sean Davis <seand...@gmail.comwrote:
On Aug 14, 6:16 am, Janto Dreijer <jan...@gmail.comwrote:
Hi!
I am looking for a Python implementation or bindings to a library that
can quickly find k-Nearest Neighbors given an arbitrary distance
metric between objects. Specifically, I have an "edit distance"
between objects that is written in Python.
I haven't looked at the methods in detail but I think I'm looking for
one of the data structures listed onhttp://en.wikipedia.org/wiki/Metric_trees
(i.e. vp-trees, cover trees, m-trees or bk trees). But I might be
wrong. An approximatekNNwould also work.
If there doesn't exist such an implementation yet, any advice on a
library I can wrap myself would also be appreciated.
Thanks!
Janto

Have you looked at using Rpy and R? There are probably severalknn
implementations that then become accessible to you (although I haven't
checked recently).

Sean
Interesting. I have not looked at that. I can't really find an R
package that does what I want, so any suggestions are appreciated.

Janto

Aug 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andreas Neudecker | last post by:
Hi. I have seen some discussions going on about making Python code faster and several measures looked fairly 'esoteric' to me (i.e.: you need to know a lot of background things to even KNOW...
5
by: K. N. | last post by:
Is there any good and fast Python module for XSLT processing ? I'm going to use XML and XSLT to generate web pages, so I need XSLT processor that will be able to transform for example a DOM object...
11
by: Sebastian Krause | last post by:
Hello, I tried to read in some large ascii files (200MB-2GB) in Python using scipy.io.read_array, but it did not work as I expected. The whole idea was to find a fast Python routine to read in...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
7
by: Johnny Lee | last post by:
Hi, First, I want to know whether the python interpreter translate the code directly into machine code, or translate it into C then into machine code? Second, if the codes are translated directly...
21
by: mm | last post by:
(Yes, I konw whats an object is...) BTW. I did a translation of a pi callculation programm in C to Python. (Do it by your own... ;-) -------- Calc PI for 800 digs(?). (german: Stellen) ------...
28
by: windandwaves | last post by:
Can someone tell me why I should learn python? I am a webdeveloper, but I often see Python mentioned and I am curious to find out what I am missing out on. Thank you Nicolaas
71
by: Jack | last post by:
I understand that the standard Python distribution is considered the C-Python. Howerver, the current C-Python is really a combination of C and Python implementation. There are about 2000 Python...
68
by: Santiago Romero | last post by:
( Surely if this question has been asked for a zillion of times... ) ( and sorry for my english! ) I'm impressed with python. I'm very happy with the language and I find Python+Pygame a very...
39
by: cm_gui | last post by:
Python is slow. Almost all of the web applications written in Python are slow. Zope/Plone is slow, sloow, so very slooow. Even Google Apps is not faster. Neither is Youtube. Facebook and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.