Skip to main content

k nearest neighbor (KNN) graphs via Pearson correlation distance and local sensitive hashing (LSH).

Project description

k nearest neighbor (KNN) graphs via Pearson correlation distance and local sensitive hashing (LSH).

import numpy as np
import lshknn

# Make mock data
# 2 features (rows), 4 samples (columns)
data = np.array(
        [[1, 0, 1, 0],
         [0, 1, 0, 1]],
        dtype=np.float64)

# Instantiate class
c = lshknn.Lshknn(
        data=data,
        k=1,
        threshold=0.2,
        m=10,
        slice_length=4)

# Call subroutine
knn, similarity, n_neighbors = c()

# Check result
assert (knn == [[2], [3], [0], [1]]).all()

Project details


Download files

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

Files for lshknn, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size lshknn-0.1.2.tar.gz (9.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page