{ "info": { "author": "Luca Cappelletti", "author_email": "cappelletti.luca94@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Information Analysis" ], "description": ".. role:: py(code)\n :language: python\n\nDictances\n==========\n\n|travis| |coveralls| |sonar_quality| |sonar_maintainability| |code_climate_maintainability| |code_climate_test_coverage| |pip|\n\nDistances and divergences between dictionaries implemented in python 3.6.\n\nIn the complexity notations, :py:`n` is :py:`len(a)` and :py:`m` is :py:`len(b)`.\n\nThe samples are dictionaries generated by the `test utilities here`_.\n\nHow do I get it?\n----------------\nJust type into your terminal:\n\n.. code:: shell\n\n pip install dictances\n\n\nBasic example\n--------------\nFor each metric, an example is present in `the folder examples`_. Here's a basic example for those too lazy to click links (like me).\n\n.. code:: python\n\n import random\n from dictances import cosine, euclidean, canberra\n random.seed(42) # for reproducibility\n\n # Simple function to generate the example dictionaries\n\n\n def generate_example_dict(n=1000):\n return {random.randint(0, 1000): random.uniform(0, 1000) for i in range(n)}\n\n\n a, b = generate_example_dict(), generate_example_dict()\n\n print(cosine(a, b))\n # >>> 0.52336690346601\n\n print(euclidean(a, b))\n # >>> 15119.400349404095\n\n print(canberra(a, b))\n # >>> 624.9088876554047\n\n\n\nMetrics table\n--------------\n\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| Metric name | Usage example | Average time on sample | Complexity |\n+================================+===============================+=============================+======================================+\n| `Euclidean distance`_ | `euclidean`_ | 90.4 \u00b5s \u00b1 2.5 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| Squared variation | `squared_variation`_ | 90.8 \u00b5s \u00b1 1.43 | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Total variation`_ | `total_variation`_ | 92.3 \u00b5s \u00b1 1.28 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| Nth variation | `nth_variation`_ | 91.1 \u00b5s \u00b1 1.2 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Manhattan distance`_ | `manhattan`_ | 92.7 \u00b5s \u00b1 1.43 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Mean absolute error`_ | `mae`_ | 92.3 \u00b5s \u00b1 1.28 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Mean squared error`_ | `mse`_ | 91.1 \u00b5s \u00b1 1.2 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Chebyshev distance`_ | `chebyshev`_ | 101 \u00b5s \u00b1 2.14 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Minkowski distance`_ | `minkowsky`_ | 91.1 \u00b5s \u00b1 2.05 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Canberra distance`_ | `canberra`_ | 71.8 \u00b5s \u00b1 1.95 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Cosine distance`_ | `cosine`_ | 61.3 \u00b5s \u00b1 835 ns | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Pearson distance`_ | `pearson`_ | 46.9 \u00b5s \u00b1 1.23 \u00b5s | |On+m| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Hamming distance`_ | `hamming`_ | 28.7 \u00b5s \u00b1 784 ns | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| Normalized Total Variation | `normal_total_variation`_ | 34.6 \u00b5s \u00b1 543 ns | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Kullback Leibler divergence`_ | `kullback_leibler`_ | 24 \u00b5s \u00b1 587 ns | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Jensen Shannon divergence`_ | `jensen_shannon`_ | 38.2 \u00b5s \u00b1 1.18 \u00b5s | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Bhattacharyya distance`_ | `bhattacharyya`_ | 32.7 \u00b5s \u00b1 655 ns | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n| `Hellinger distance`_ | `hellinger`_ | 42 \u00b5s \u00b1 467 ns | |Omin| |\n+--------------------------------+-------------------------------+-----------------------------+--------------------------------------+\n\nTest computer specifications\n----------------------------\n\nThe computer on which the metrics where timed had the following specifications:\n\n+---------------------------------------+\n| Computer specifications |\n+=======================+===============+\n| Model Name | MacBook Pro |\n+-----------------------+---------------+\n| Processor Name | Intel Core i7 |\n+-----------------------+---------------+\n| Processor Speed | 2.3 GHz |\n+-----------------------+---------------+\n| Number of Processors | 1 |\n+-----------------------+---------------+\n| Total Number of Cores | 4 |\n+-----------------------+---------------+\n| L2 Cache (per Core) | 256 KB |\n+-----------------------+---------------+\n| L3 Cache | 6 MB |\n+-----------------------+---------------+\n| Memory | 16 GB |\n+-----------------------+---------------+\n\n.. |travis| image:: https://travis-ci.org/LucaCappelletti94/dictances.png\n :target: https://travis-ci.org/LucaCappelletti94/dictances\n\n.. |coveralls| image:: https://coveralls.io/repos/github/LucaCappelletti94/distances/badge.svg?branch=master\n :target: https://coveralls.io/github/LucaCappelletti94/distances\n\n.. |sonar_quality| image:: https://sonarcloud.io/api/project_badges/measure?project=dictances.lucacappelletti&metric=alert_status\n :target: https://sonarcloud.io/dashboard/index/dictances.lucacappelletti\n\n.. |sonar_maintainability| image:: https://sonarcloud.io/api/project_badges/measure?project=dictances.lucacappelletti&metric=sqale_rating\n :target: https://sonarcloud.io/dashboard/index/dictances.lucacappelletti\n\n.. |code_climate_maintainability| image:: https://api.codeclimate.com/v1/badges/25fb7c6119e188dbd12c/maintainability\n :target: https://codeclimate.com/github/LucaCappelletti94/dictances/maintainability\n :alt: Maintainability\n\n.. |code_climate_test_coverage| image:: https://api.codeclimate.com/v1/badges/25fb7c6119e188dbd12c/test_coverage\n :target: https://codeclimate.com/github/LucaCappelletti94/dictances/test_coverage\n :alt: Test Coverage\n\n.. |pip| image:: https://badge.fury.io/py/dictances.svg\n :target: https://badge.fury.io/py/dictances\n\n.. _Euclidean distance: https://en.wikipedia.org/wiki/Euclidean_distance\n.. _Manhattan distance: https://en.wikipedia.org/wiki/Taxicab_geometry\n.. _Jensen Shannon divergence: https://en.wikipedia.org/wiki/Jensen%E2%80%93Shannon_divergence\n.. _Bhattacharyya distance: https://en.wikipedia.org/wiki/Bhattacharyya_distance\n.. _Total variation: https://en.wikipedia.org/wiki/Total_variation\n.. _Hellinger distance: https://en.wikipedia.org/wiki/Hellinger_distance\n.. _Kullback Leibler divergence: https://en.wikipedia.org/wiki/Hellinger_distance\n.. _Mean absolute error: https://en.wikipedia.org/wiki/Mean_absolute_error\n.. _Mean squared error: https://en.wikipedia.org/wiki/Mean_squared_error\n.. _Chebyshev distance: https://en.wikipedia.org/wiki/Chebyshev_distance\n.. _Minkowski distance: https://en.wikipedia.org/wiki/Minkowski_distance\n.. _Canberra distance: https://en.wikipedia.org/wiki/Canberra_distance\n.. _Cosine distance: https://en.wikipedia.org/wiki/Cosine_similarity\n.. _Pearson distance: https://en.wikipedia.org/wiki/Pearson_correlation_coefficient\n.. _Hamming distance: https://en.wikipedia.org/wiki/Hamming_distance\n\n.. _euclidean: https://github.com/LucaCappelletti94/distances/blob/master/examples/euclidean.py\n.. _jensen_shannon: https://github.com/LucaCappelletti94/distances/blob/master/examples/jensen_shannon.py\n.. _bhattacharyya: https://github.com/LucaCappelletti94/distances/blob/master/examples/bhattacharyya.py\n.. _total_variation: https://github.com/LucaCappelletti94/distances/blob/master/examples/total_variation.py\n.. _squared_variation: https://github.com/LucaCappelletti94/distances/blob/master/examples/squared_variation.py\n.. _nth_variation: https://github.com/LucaCappelletti94/distances/blob/master/examples/nth_variation.py\n.. _hellinger: https://github.com/LucaCappelletti94/distances/blob/master/examples/hellinger.py\n.. _kullback_leibler: https://github.com/LucaCappelletti94/distances/blob/master/examples/kullback_leibler.py\n.. _manhattan: https://github.com/LucaCappelletti94/distances/blob/master/examples/manhattan.py\n.. _mae: https://github.com/LucaCappelletti94/distances/blob/master/examples/mae.py\n.. _mse: https://github.com/LucaCappelletti94/distances/blob/master/examples/mse.py\n.. _chebyshev: https://github.com/LucaCappelletti94/distances/blob/master/examples/chebyshev.py\n.. _minkowsky: https://github.com/LucaCappelletti94/distances/blob/master/examples/minkowski.py\n.. _canberra: https://github.com/LucaCappelletti94/distances/blob/master/examples/canberra.py\n.. _cosine: https://github.com/LucaCappelletti94/distances/blob/master/examples/cosine.py\n.. _pearson: https://github.com/LucaCappelletti94/distances/blob/master/examples/pearson.py\n.. _hamming: https://github.com/LucaCappelletti94/distances/blob/master/examples/hamming.py\n.. _normal_total_variation: https://github.com/LucaCappelletti94/distances/blob/master/examples/normal_total_variation.py\n\n.. _test utilities here: https://github.com/LucaCappelletti94/distances/blob/master/tests/helpers/utils.py\n.. _the folder examples: https://github.com/LucaCappelletti94/distances/tree/master/examples\n\n.. |On+m| image:: https://github.com/LucaCappelletti94/distances/blob/master/images/On+m.gif?raw=true\n.. |Omin| image:: https://github.com/LucaCappelletti94/distances/blob/master/images/Omin.gif?raw=true\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/LucaCappelletti94/dictances", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dictances", "package_url": "https://pypi.org/project/dictances/", "platform": "", "project_url": "https://pypi.org/project/dictances/", "project_urls": { "Homepage": "https://github.com/LucaCappelletti94/dictances" }, "release_url": "https://pypi.org/project/dictances/1.5.0/", "requires_dist": null, "requires_python": "", "summary": "Distances and divergences between distributions implemented in python.", "version": "1.5.0" }, "last_serial": 3942864, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "a37a93fded75744dd10f2b9edc746c4c", "sha256": "b41d70cb4dd68a29db614dde572d3337b7f750751bd2417f38ab19dba1e646d0" }, "downloads": -1, "filename": "dictances-1.1.0.tar.gz", "has_sig": false, "md5_digest": "a37a93fded75744dd10f2b9edc746c4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8055, "upload_time": "2018-05-14T16:37:40", "url": "https://files.pythonhosted.org/packages/d8/34/aa48dfc60ed0551e52036e1e7c335319154e27311f0a1c905aecaf2f5ff5/dictances-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "3b0ddce9ccf5a39a366e1dc13ed739b0", "sha256": "9842a65d7af65296806003f7fb4e5009b255068c1c4634369ab5299a9b33c9e1" }, "downloads": -1, "filename": "dictances-1.1.1.tar.gz", "has_sig": false, "md5_digest": "3b0ddce9ccf5a39a366e1dc13ed739b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8171, "upload_time": "2018-05-14T18:03:21", "url": "https://files.pythonhosted.org/packages/2f/5d/db656bf4503fbb38c5cf074c7eb2877006ba4898f08d2964c62addbe4cfc/dictances-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "eb9e9ac7f86865b7dd9ae6bc8a9ee171", "sha256": "3750fc65e716858b861fdf5fe995387b39d91b2efab2fbb7a3be38e7445b7fc9" }, "downloads": -1, "filename": "dictances-1.1.2.tar.gz", "has_sig": false, "md5_digest": "eb9e9ac7f86865b7dd9ae6bc8a9ee171", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8163, "upload_time": "2018-05-14T18:04:04", "url": "https://files.pythonhosted.org/packages/11/ee/e0d2dc7fafef5ff533975d39d5b132c1904a1a722c5551eb6039132ec0af/dictances-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "fe1dd4ab5041a4e41e8c36c9cfbef4dc", "sha256": "8de5079654c6851be2d683cabdc55548b422dfba397fb663e3119264fd123894" }, "downloads": -1, "filename": "dictances-1.1.3.tar.gz", "has_sig": false, "md5_digest": "fe1dd4ab5041a4e41e8c36c9cfbef4dc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8115, "upload_time": "2018-05-15T07:10:19", "url": "https://files.pythonhosted.org/packages/28/09/610bd49641463770d3d9976fa0a6089228e3a8ad23defaadce7ceb734800/dictances-1.1.3.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "0f63c2b39d2c1cd967384eb3a441a330", "sha256": "ec651b2dd394c30a60002b96e507550cbf69db3022ee0485117370d76ca0fb86" }, "downloads": -1, "filename": "dictances-1.1.4.tar.gz", "has_sig": false, "md5_digest": "0f63c2b39d2c1cd967384eb3a441a330", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8129, "upload_time": "2018-05-15T07:13:32", "url": "https://files.pythonhosted.org/packages/bc/b4/d64af57316ea3b4342763f10998780e25a9f8216f57e1ae43b47bbf5603c/dictances-1.1.4.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "d5424f35f8d1a68d355d6ecfa01df5ec", "sha256": "1de90aea885499ab4b008aff9017e53891733f2ad247b86c28ed95270ad6266a" }, "downloads": -1, "filename": "dictances-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d5424f35f8d1a68d355d6ecfa01df5ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8383, "upload_time": "2018-05-17T07:54:59", "url": "https://files.pythonhosted.org/packages/43/9d/196a7c0cd5c405d0260d2040403f61596e49c02a6b70868d888c62ad1036/dictances-1.2.0.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "53d5dc5de4fdfe58affd609130391b38", "sha256": "9d08dfa64df227385474ef5e7d69b46d6edb9231807c6098f1e34bee1267876d" }, "downloads": -1, "filename": "dictances-1.3.0.tar.gz", "has_sig": false, "md5_digest": "53d5dc5de4fdfe58affd609130391b38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8601, "upload_time": "2018-05-19T06:58:24", "url": "https://files.pythonhosted.org/packages/ae/ae/241214d4eba27ab101445332efa357c58788bb9c24fe5272a99e3bc6bc49/dictances-1.3.0.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "06a2d1b2ef0fd2316eac3177ebb899da", "sha256": "46fc2ed40648daaebca58d3f0e1e2ce7d97b51f7c5634fe3a380a2a83163b5e7" }, "downloads": -1, "filename": "dictances-1.4.0.tar.gz", "has_sig": false, "md5_digest": "06a2d1b2ef0fd2316eac3177ebb899da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8891, "upload_time": "2018-05-30T06:57:37", "url": "https://files.pythonhosted.org/packages/1b/57/ce6e79fbee5f156e41104a60c4b6d51ccc3e1d146cc49ba64eefbb813432/dictances-1.4.0.tar.gz" } ], "1.4.1": [ { "comment_text": "", "digests": { "md5": "4cb2b253075c9cbf5ad5c93e365e0b46", "sha256": "97f462f5c79bb4d57198b92601e46c4ca765c9c94cfd9e2ff46fc13286b4adab" }, "downloads": -1, "filename": "dictances-1.4.1.tar.gz", "has_sig": false, "md5_digest": "4cb2b253075c9cbf5ad5c93e365e0b46", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8926, "upload_time": "2018-05-30T07:26:28", "url": "https://files.pythonhosted.org/packages/59/34/7df4695df63a9293f2c8330b239ca3c2ecf4c9cc08386091ec19d0fa5883/dictances-1.4.1.tar.gz" } ], "1.4.2": [ { "comment_text": "", "digests": { "md5": "a814c0d040964be4ecd69f1742f2c884", "sha256": "a66059787ce7e9baa773637a608189c6e0badd95d7b903e89e633c9516f73d09" }, "downloads": -1, "filename": "dictances-1.4.2.tar.gz", "has_sig": false, "md5_digest": "a814c0d040964be4ecd69f1742f2c884", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8809, "upload_time": "2018-06-06T13:58:58", "url": "https://files.pythonhosted.org/packages/4c/e8/92eaf43c18a091d17eb9d59af8525a7b8daef17c596f78ccaabe3cfa090a/dictances-1.4.2.tar.gz" } ], "1.4.3": [ { "comment_text": "", "digests": { "md5": "46da6ab17b7c14a94cf64d2df241df25", "sha256": "78022e736de11ac3332ec32a4247cff3571685706b3e1d402f19c31d44a112eb" }, "downloads": -1, "filename": "dictances-1.4.3.tar.gz", "has_sig": false, "md5_digest": "46da6ab17b7c14a94cf64d2df241df25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8838, "upload_time": "2018-06-06T14:12:32", "url": "https://files.pythonhosted.org/packages/49/ee/db42b582e41d927d176a89af2c8edf192948b0b12637bb0179eccfe2fd3f/dictances-1.4.3.tar.gz" } ], "1.4.4": [ { "comment_text": "", "digests": { "md5": "18c7d7e71f9b12923905245b6c6650b5", "sha256": "8cfed63865d0c0c3c446b68518627cbad41f00aec0e45ab9a5dbaab413668bb0" }, "downloads": -1, "filename": "dictances-1.4.4.tar.gz", "has_sig": false, "md5_digest": "18c7d7e71f9b12923905245b6c6650b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8823, "upload_time": "2018-06-07T04:58:48", "url": "https://files.pythonhosted.org/packages/7c/d2/4df66f7a76e96d8c7cc999d2e22b06c5180abf9ac6cb144aed900c16923d/dictances-1.4.4.tar.gz" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "baefb9534d3061fee43be9b480706532", "sha256": "8069810481e9d38ac4923382deaa1705508e52495dc38c6bc2f15f60320f6752" }, "downloads": -1, "filename": "dictances-1.5.0.tar.gz", "has_sig": false, "md5_digest": "baefb9534d3061fee43be9b480706532", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9412, "upload_time": "2018-06-08T13:21:09", "url": "https://files.pythonhosted.org/packages/b5/66/136be252a7ec7e9b243388eb6b68aca70ab2468b932490fdcd9d01c91007/dictances-1.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "baefb9534d3061fee43be9b480706532", "sha256": "8069810481e9d38ac4923382deaa1705508e52495dc38c6bc2f15f60320f6752" }, "downloads": -1, "filename": "dictances-1.5.0.tar.gz", "has_sig": false, "md5_digest": "baefb9534d3061fee43be9b480706532", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9412, "upload_time": "2018-06-08T13:21:09", "url": "https://files.pythonhosted.org/packages/b5/66/136be252a7ec7e9b243388eb6b68aca70ab2468b932490fdcd9d01c91007/dictances-1.5.0.tar.gz" } ] }