mlpack.lsh

lsh(...)
K-Approximate-Nearest-Neighbor Search with LSH

>>> from mlpack import lsh

This program will calculate the k approximate-nearest-neighbors of a set of points using locality-sensitive hashing. You may specify a separate set of reference points and query points, or just a reference set which will be used as both the reference and query set.

For example, the following will return 5 neighbors from the data for each point in 'input' and store the distances in 'distances' and the neighbors in 'neighbors':

>>> output = lsh(k=5, reference=input)
>>> distances = output['distances']
>>> neighbors = output['neighbors']

The output is organized such that row i and column j in the neighbors output corresponds to the index of the point in the reference set which is the j'th nearest neighbor from the point in the query set with index i. Row j and column i in the distances output file corresponds to the distance between those two points.

Because this is approximate-nearest-neighbors search, results may be different from run to run. Thus, the 'seed' parameter can be specified to set the random seed.

This program also has many other parameters to control its functionality; see the parameter-specific documentation for more information.

input options

output options

The return value from the binding is a dict containing the following elements: