Skip to main content

flann is the python 3.6 bindings for FLANN - Fast Library for Approximate Nearest Neighbors.

Project description

1. Introduction

pyflann is the python bindings for FLANN - Fast Library for Approximate Nearest Neighbors.

2. Install

For python2

This package uses distutils, which is the default way of installing python modules. To install in your home directory, securely run the following:

git clone https://github.com/primetang/pyflann.git
cd pyflann
[sudo] python setup.py install

Or directly through pip to install it:

[sudo] pip install pyflann

For python3

Please refer to this issuse to modify the code.

3. Usage

Use it just like the following code:

from pyflann import *
import numpy as np

dataset = np.array(
    [[1., 1, 1, 2, 3],
     [10, 10, 10, 3, 2],
     [100, 100, 2, 30, 1]
     ])
testset = np.array(
    [[1., 1, 1, 1, 1],
     [90, 90, 10, 10, 1]
     ])
flann = FLANN()
result, dists = flann.nn(
    dataset, testset, 2, algorithm="kmeans", branching=32, iterations=7, checks=16)
print result
print dists

dataset = np.random.rand(10000, 128)
testset = np.random.rand(1000, 128)
flann = FLANN()
result, dists = flann.nn(
    dataset, testset, 5, algorithm="kmeans", branching=32, iterations=7, checks=16)
print result
print dists

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flann-1.6.13.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

flann-1.6.13-py3-none-any.whl (24.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page