Skip to main content

Distances and divergences between distributions implemented in python.

Project description

Travis CI build SonarCloud Quality SonarCloud Maintainability Codacy Maintainability Maintainability Pypi project Pypi total project downloads

Distances and divergences between distributions implemented in python.

How do I install this package?

As usual, just download it using pip:

pip install dictances

Tests Coverage

Since some software handling coverages sometime get slightly different results, here’s three of them:

Coveralls Coverage SonarCloud Coverage Code Climate Coverate

Available metrics

A number of distances and divergences are available:

Distances

Methods

Bhattacharyya distance

bhattacharyya

Bhattacharyya coefficient

bhattacharyya_coefficient

Canberra distance

canberra

Chebyshev distance

chebyshev

Cosine Distance

cosine

Euclidean distance

euclidean

Hamming distance

hamming

Jensen-Shannon divergence

jensen_shannon

Kullback-Leibler divergence

kullback_leibler

Mean absolute error

mae

Taxicab geometry

manhattan, cityblock, total_variation

Minkowski distance

minkowsky

Mean squared error

mse

Pearson’s distance

pearson

Squared deviations from the mean

squared_variation

Usage example

from dictances import cosine

cosine(my_first_dictionary, my_second_dictionary)

Handling nested dictionaries

If you need to compute the distance between two nested dictionaries you can use deflate_dict as follows:

from dictances import cosine
from deflate_dict import deflate

my_first_dictionary = {
    "a": 8,
    "b": {
        "c": 3,
        "d": 6
    }
}

my_second_dictionary = {
    "b": {
        "c": 8,
        "d": 1
    },
    "y": 3,

}

cosine(deflate(my_first_dictionary), deflate(my_second_dictionary))

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

dictances-1.5.1.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file dictances-1.5.1.tar.gz.

File metadata

  • Download URL: dictances-1.5.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for dictances-1.5.1.tar.gz
Algorithm Hash digest
SHA256 fe7be5674595f9f0435a4670035ec16a78cbf8415e6c6ca64431c9628d4c88f5
MD5 fecc55e0010aad1151cf652bba851d62
BLAKE2b-256 c42da884c8183015fc9fffe115d80f9487733bcf40a3e6f88c99041164355468

See more details on using hashes here.

Provenance

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