A fuzzy matching & clustering library for python.
Go to file
Yomguithereal 6dc0ec3135 Bump 0.1.1 2018-05-30 12:34:19 +02:00
fog Light optimization 2018-05-30 11:28:23 +02:00
test Adding weighted Jaccard similarity 2018-05-30 10:49:07 +02:00
.gitignore Improving publish process 2018-04-27 14:54:40 +02:00
.travis.yml Dropping py33 from CI 2018-04-27 14:21:05 +02:00
LICENSE.txt Fixing 2018-05-18 15:59:00 +02:00
Makefile Adding weighted Jaccard similarity 2018-05-30 10:49:07 +02:00
README.md Adding weighted Jaccard similarity 2018-05-30 10:49:07 +02:00
requirements.txt Improving publish process 2018-04-27 14:54:40 +02:00
setup.py Bump 0.1.1 2018-05-30 12:34:19 +02:00

README.md

Build Status

Fog

A fuzzy matching/clustering library for Python.

Installation

You can install fog with pip with the following command:

pip install fog

Usage

Metrics

sparse_cosine_similarity

Computes the cosine similarity of two sparse weighted sets. Those sets have to be represented as counters.

from fog.metrics import sparse_cosine_similarity

# Basic
sparse_cosine_similarity({'apple': 34, 'pear': 3}, {'pear': 1, 'orange': 1})
>>> ~0.062

# Using custom key
A = {'apple': {'weight': 34}, 'pear': {'weight': 3}}
B = {'pear': {'weight': 1}, 'orange': {'weight': 1}}
sparse_cosine_similarity(A, B, key=lambda x: x['weight'])

Arguments

  • A Counter: first weighted set. Must be a dictionary mapping keys to weights.
  • B Counter: second weighted set. Muset be a dictionary mapping keys to weights.
  • key ?callable: Optional function retrieving the weight from values.

weighted_jaccard_similarity

Computes the weighted Jaccard similarity of two weighted sets. Those sets have to be represented as counters.

from fog.metrics import weighted_jaccard_similarity

# Basic
weighted_jaccard_similarity({'apple': 34, 'pear': 3}, {'pear': 1, 'orange': 1})
>>> ~0.026

# Using custom key
A = {'apple': {'weight': 34}, 'pear': {'weight': 3}}
B = {'pear': {'weight': 1}, 'orange': {'weight': 1}}
weighted_jaccard_similarity(A, B, key=lambda x: x['weight'])

Arguments

  • A Counter: first weighted set. Must be a dictionary mapping keys to weights.
  • B Counter: second weighted set. Muset be a dictionary mapping keys to weights.
  • key ?callable: Optional function retrieving the weight from values.