ekzhu / datasketch

MinHash, LSH, LSH Forest, Weighted MinHash, HyperLogLog, HyperLogLog++, LSH Ensemble and HNSW
https://ekzhu.github.io/datasketch
MIT License
2.59k stars 295 forks source link
data-sketches data-summary hnsw hyperloglog jaccard-similarity locality-sensitive-hashing lsh lsh-ensemble lsh-forest minhash python search top-k weighted-quantiles

datasketch: Big Data Looks Small

.. image:: https://static.pepy.tech/badge/datasketch/month :target: https://pepy.tech/project/datasketch

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.598238.svg :target: https://zenodo.org/doi/10.5281/zenodo.598238

datasketch gives you probabilistic data structures that can process and search very large amount of data super fast, with little loss of accuracy.

This package contains the following data sketches:

+-------------------------+-----------------------------------------------+ | Data Sketch | Usage | +=========================+===============================================+ | MinHash | estimate Jaccard similarity and cardinality | +-------------------------+-----------------------------------------------+ | Weighted MinHash | estimate weighted Jaccard similarity | +-------------------------+-----------------------------------------------+ | HyperLogLog | estimate cardinality | +-------------------------+-----------------------------------------------+ | HyperLogLog++ | estimate cardinality | +-------------------------+-----------------------------------------------+

The following indexes for data sketches are provided to support sub-linear query time:

+---------------------------+-----------------------------+------------------------+ | Index | For Data Sketch | Supported Query Type | +===========================+=============================+========================+ | MinHash LSH | MinHash, Weighted MinHash | Jaccard Threshold | +---------------------------+-----------------------------+------------------------+ | MinHash LSH Forest | MinHash, Weighted MinHash | Jaccard Top-K | +---------------------------+-----------------------------+------------------------+ | MinHash LSH Ensemble | MinHash | Containment Threshold | +---------------------------+-----------------------------+------------------------+ | HNSW | Any | Custom Metric Top-K | +---------------------------+-----------------------------+------------------------+

datasketch must be used with Python 3.7 or above, NumPy 1.11 or above, and Scipy.

Note that MinHash LSH and MinHash LSH Ensemble also support Redis and Cassandra storage layer (see MinHash LSH at Scale_).

Install

To install datasketch using pip:

::

pip install datasketch

This will also install NumPy as dependency.

To install with Redis dependency:

::

pip install datasketch[redis]

To install with Cassandra dependency:

::

pip install datasketch[cassandra]

.. MinHash: https://ekzhu.github.io/datasketch/minhash.html .. Weighted MinHash: https://ekzhu.github.io/datasketch/weightedminhash.html .. HyperLogLog: https://ekzhu.github.io/datasketch/hyperloglog.html .. HyperLogLog++: https://ekzhu.github.io/datasketch/hyperloglog.html#hyperloglog-plusplus .. MinHash LSH: https://ekzhu.github.io/datasketch/lsh.html .. MinHash LSH Forest: https://ekzhu.github.io/datasketch/lshforest.html .. MinHash LSH Ensemble: https://ekzhu.github.io/datasketch/lshensemble.html .. Minhash LSH at Scale: http://ekzhu.github.io/datasketch/lsh.html#minhash-lsh-at-scale .. _HNSW: https://ekzhu.github.io/datasketch/documentation.html#hnsw