Skip to main content

A package implementing a vantage-point data structure, for efficient nearest neighbor searching.

Project description

https://badge.fury.io/py/vptree.svg https://app.travis-ci.com/RickardSjogren/vptree.svg?branch=master

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.3.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file vptree-1.3.tar.gz.

File metadata

  • Download URL: vptree-1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for vptree-1.3.tar.gz
Algorithm Hash digest
SHA256 a412a833a6ab18936b96c5e21177a462fb438b26d285e258cb836df8fd01a97d
MD5 9684daa84576d299f4301918b871b552
BLAKE2b-256 38f5535b223cc11368d7b30059a72fc4a23797d509a6d491df6f3f3d99652bea

See more details on using hashes here.

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