A 1&2-stable Locality-Sensitive Hashing implementation in Python
Project description
P-stable-LSH
The package is one implementation of paper Locality-Sensitive Hashing Scheme Based on p-Stable Distributions in SCG’2014.
test case
data = [np.random.random(100) for _ in range(2)]
m1 = pstable(50, metric_dim=1, num_perm=200000)
m1.lsh(data[0])
m2 = pstable(50, metric_dim=1, num_perm=200000)
m2.lsh(data[1])
print(m1.jaccard(m2)) # estimate value
print(m1.p(np.average(sum(np.abs(data[0]-data[1]))))) # theoretical(true) value
m1 = pstable(50, metric_dim=2, num_perm=200000)
m1.lsh(data[0])
m2 = pstable(50, metric_dim=2, num_perm=200000)
m2.lsh(data[1])
print(m1.jaccard(m2)) # estimate value
print(m1.p(np.sqrt(sum([i**2 for i in data[0]-data[1]])))) # theoretical(true) value
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file p-stable-lsh-python-0.0.1.tar.gz
.
File metadata
- Download URL: p-stable-lsh-python-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f05198163dc622582989b0eea1f469a164d048befaa05c56a8efb51197f8764e |
|
MD5 | 9f57ba62fb946493909e605c41f36f4a |
|
BLAKE2b-256 | 6c35f36ed0d8506b5ece7be8ae103d84a8b2f58c5dddd8cbf10b99c6241d406a |
File details
Details for the file p_stable_lsh_python-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: p_stable_lsh_python-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b864d6ad8151dddaa9a22cad0f41e73accc63682cab3a388a7418faf2e03da2 |
|
MD5 | 73aecfe83714368ca86205962587bbf0 |
|
BLAKE2b-256 | 547fbcefb5502734f4e2f130a1bcb1a6375474cf5c36fb9b1e9841332ede00be |