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.
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 Distribution
vptree-1.2.tar.gz
(4.1 kB
view details)
File details
Details for the file vptree-1.2.tar.gz
.
File metadata
- Download URL: vptree-1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23b7d71e6840480f58ceb573dd24ff8e365ca32753a0f997a5fcb65a1f4d4340 |
|
MD5 | 3cda827a0b54a8dc94492d276348f6a1 |
|
BLAKE2b-256 | 6dbeed4f57bdaa34fe3431af28943b57f42959e63b668b1a3b9864d647185106 |