Skip to main content

A fast Python implementation of locality sensitive hashing with cosine distance

Installation

LSHCos depends on the following libraries:

  • numpy

To install:

$ pip install lshcos

Quickstart

To create band 2 row 6 hashes for input data of 8 dimensions:

import numpy as np
from lshcos import LSHCos

### usage one:
lshcos = LSHCos(2, 6, 8)
lshcos.add([1,2,3,4,5,6,7,8],'v_1')
lshcos.add([2,3,4,5,6,7,8,9],'v_2')
lshcos.add([10,12,99,1,5,31,2,3],'v_3')
lshcos.query([1,2,3,4,5,6,7,7],2)

### usage two:
lshcos = LSHCos(2, 6, 8)
xxx = [('v_'+str(i),np.random.randn(8)) for i in range(100)]
yyy = np.random.randn(8)
for name,v in xxx:
    lshcos.add(v,name)
lshcos.query(yyy)

Main Interface

  • To initialize a LSHCos instance:

LSHCos(band_num, row_num, v_dim)

parameters:

band_num:

The number of band.

row_num:

The number of row for each band.

v_dim:

The dimension of the input vector.

Metadata

Release files for lshcos 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lshcos 0.0.2
File Size Uploaded Provenance
lshcos-0.0.2.tar.gz 2.8 kB Without provenance Details

Release files / lshcos-0.0.2.tar.gz

Download URL lshcos-0.0.2.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6140c593ee190082d9033b196ca4a43509986d05846eff02b2510120bee1d390
BLAKE2b-256 checksum
How to use checksums
f533d3a3f94a1f82fe0c3ffbeceb4ea9148b1eb391de8a51c3103d84e3393065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Security for lshcos 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page