Skip to main content

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

Chi Square distance

chi_square

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))

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

Uploaded Source

File details

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

File metadata

  • Download URL: dictances-1.5.2.tar.gz
  • Upload date:
  • Size: 8.6 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.2.tar.gz
Algorithm Hash digest
SHA256 66cbe49c272baf4101a0a6504c8129f6a79399d2167d990fd378b8deed5d878a
MD5 3b3859c9f46d9c9e22d76570dfa79867
BLAKE2b-256 bd49a5a430d3a74f43e29c9481ab830cd0353142e3cf70cd2da659132ee5a948

See more details on using hashes here.

Release history Release notifications | RSS feed

1.5.6

1 file

1.5.5

1 file

1.5.4

1 file

1.5.3

1 file

This release

1.5.2 This release

1 file

1.5.1

1 file

1.5.0

1 file

1.4.4

1 file

1.4.3

1 file

1.4.2

1 file

1.4.1

1 file

1.4.0

1 file

1.3.0

1 file

1.2.0

1 file

1.1.4

1 file

1.1.3

1 file

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page