Skip to main content

A fuzzy matching & clustering library for python.

Project description

[![Build Status](https://travis-ci.org/Yomguithereal/fog.svg)](https://travis-ci.org/Yomguithereal/fog)

# Fog

A fuzzy matching/clustering library for Python.

## Installation

You can install `fog` with pip with the following command:

```
pip install fog
```

## Usage

* [Metrics](#metrics)
- [sparse_cosine_similarity](#sparse_cosine_similarity)

### Metrics

#### sparse_cosine_similarity

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

```python
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.

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.0.1.tar.gz (2.5 kB view hashes)

Uploaded Source

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