A fuzzy matching & clustering library for python.
Project description
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
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.
jaccard_similarity
Computes the Jaccard similarity of two arbitrary iterables.
from fog.metrics import jaccard_similarity
# Basic
jaccard_similarity('context', 'contact')
>>> ~0.571
Arguments
- A iterable: first sequence to compare.
- B iterable: second sequence to compare.
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
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.
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
fog-0.8.1.tar.gz
(70.8 kB
view hashes)
Built Distribution
Close
Hashes for fog-0.8.1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab8ba3e31cf36acccaf0e1dc9ebf5e7f5d56cbfb8b3f2362f48906b815e6be0b |
|
MD5 | a066740ffb0214bdfd7d7f32e91bc1d5 |
|
BLAKE2b-256 | de65f82853c129e1481c95ca39a2414b7a1f98b20d2f43d7e4d4377cd82b9f8f |