A package implementing a vantage-point data structure, for efficient nearest neighbor searching.
Project description
This package contains an implementation of a vantage-point tree data structure.
Installation
Simply install through pip:
pip install vptree
Example
Example usage:
import numpy as np
import vptree
# Define distance function.
def euclidean(p1, p2):
return np.sqrt(np.sum(np.power(p2 - p1, 2)))
# Generate some random points.
points = np.random.randn(20000, 10)
query = [.5] * 10
# Build tree in O(n log n) time complexity, optionally specify minimum
# leaf size passing 'leaf_size' key word.
tree = vptree.VPTree(points, euclidean)
# Query single point.
tree.get_nearest_neighbor(query)
# Query n-points.
tree.get_n_nearest_neighbors(query, 10)
# Get all points within certain distance.
tree.get_all_in_range(query, 3.14)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for vptree-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c19d8b8b6cb67cd79327661eb13a5064c786124c546ee132dcc32661ae6493d8 |
|
MD5 | 4dee01b61af6ec7d9531b0b4c18c6a41 |
|
BLAKE2b-256 | 87576a07b00285b4dffc788cd10c9cd1de104db6bdb17944a34275dd357fec36 |