Giter Site home page Giter Site logo

guenthermi / fast_minh Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

Python package for fast MinHash calculation and operations

License: Apache License 2.0

Makefile 1.22% CMake 2.66% C++ 59.93% C 3.94% Python 32.26%
jaccard lsh minhash search similarity

fast_minh's Introduction

fast_minh

A small Python package for calculating MinHash values, computing approaximated Jaccard similarity, and building LSH indices of MinHash values to perform fast approximated set similarity search.

Installation

pip install .

Usage

Calculating MinHash values:

To calculate min hash values, you can create a HashFamily object which initializes a set of hash fuctions (default: 128). After that you can use the HashFamily.minh function to obtain a set of MinHash values for a given set of strings:

hf = HashFamily()
mh = hf.minh(['test', 'it', 'out'])

Calculate an approximated Jaccard coefficient:

After calculating multiple minhash values for different sets with the same hash family, you can use the jaccard function to determine and approximated similarity score:

from fast_minh import minh, jaccard
hf = HashFamily()
mh1 = hf.minh(['test', 'it', 'out'])
mh2 = hf.minh(['test', 'it', 'again'])
sim = jaccard(mh1, mh2)

MinHash LSH Index:

To find similar sets of text values fast, you can use an MinHash LSH index. You can insert sets with the LshIndex.insert function and retrieve similar candidates with the LshIndex.find method:

from fast_minh import LshIndex
lsh = LshIndex(1, 3)
input_key = 'Key'
input_set = ['A', 'set', 'of', 'multiple', 'tokens']
lsh.insert(input_key, input_set)
out = lsh.find(input_set)

fast_minh's People

Contributors

guenthermi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.