Skip to main content

A fuzzy matching & clustering library for python.

Project description

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.

Project details


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.1.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

fog-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file fog-0.1.1.tar.gz.

File metadata

  • Download URL: fog-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fog-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6031ae446128b483b87996d1208e0164b07773efd4282e926e0593938e289b56
MD5 8d39f535ad8ce5a4646e1e4a8242ba0c
BLAKE2b-256 61e5665dd1567a25583c6d98ded5e5d11b3b749f77bd6efa354840103577ff01

See more details on using hashes here.

File details

Details for the file fog-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fog-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6db6e86834a4c395ce8bc42e9b3b187d4e5b40735ff57ffb8b41e4852845ec8
MD5 aa7a9790f9cfeeeb41e9656b0c113af4
BLAKE2b-256 97dacc8c66fd6f981385d63f3413d3f4c199191338bf29e66710773c3c8f2750

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page