Skip to main content

pydist2 is a library that provides a set of methods for calculating distances between observations.

Project description

pydist2

https://img.shields.io/pypi/v/pydist2.svg https://img.shields.io/travis/Harmouch101/pydist2.svg Documentation Status https://img.shields.io/pypi/status/pydist2.svg https://img.shields.io/pypi/wheel/pydist2.svg https://img.shields.io/github/license/Harmouch101/pydist2.svg

pydist2 is a python library that provides a set of methods for calculating distances between observations. There are two main classes:

  • pdist1 which calculates the pairwise distances between observations in one matrix and returns a distance matrix.

  • pdist2 computes the distances between observations in two matrices and also returns a distance matrix.

Usage

pdist1(P, metric = "euclidean", matrix=False)
pdist2(P, Q, metric = "minkowski", exp = 3)

Arguments:

  • two matrices P and Q.

  • metric: The distance function to use.

  • exp: The exponent of the Minkowski distance.

Installation

The pydist2 library is available on Pypi. Thus, you can install the latest available version using pip:

$pip install pydist2

Supported Python versions

pydist2 has been tested with Python 3.7 and 3.8.

For more information, please checkout the documentation which is available at readthedocs.

This program and the accompanying materials are made available under the terms of the MIT License.

Progress & Features

  • [X] Commit the first code’s version.

  • [X] Support the following list of distances.

  • [X] Display the distance in a matrix form(a combination for each pair of points):

    >>> X = np.array([[100, 100],[0, 100],[100, 0], [500, 400], [300, 600]])
    >>> pdist1(X,matrix=True) # by default, metric = 'euclidean'
    array([[100.    , 100.    , 100.    ,   0.    , 100.    ],
           [100.    , 100.    , 100.    , 100.    ,   0.    ],
           [500.    , 100.    , 100.    , 500.    , 400.    ],
           [538.5165, 100.    , 100.    , 300.    , 600.    ],
           [141.4214,   0.    , 100.    , 100.    ,   0.    ],
           [583.0952,   0.    , 100.    , 500.    , 400.    ],
           [583.0952,   0.    , 100.    , 300.    , 600.    ],
           [565.6854, 100.    ,   0.    , 500.    , 400.    ],
           [632.4555, 100.    ,   0.    , 300.    , 600.    ],
           [282.8427, 500.    , 400.    , 300.    , 600.    ]])

where the first column represents the distance between each pair of observations. for instance, the euclidean distance between (100. , 100.) and ( 0. , 100.) is 100.

  • [X] Support numpy arrays of the same size only.

Todo list

  • [ ] Re-validate the correctness of the distances equations.

  • [ ] Performance tests & vectorization.

  • [ ] Adding new distances.

  • [ ] Adding a squared form of the distance.

  • [ ] Support tuples and list.

  • [ ] Write more test cases.

  • [ ] Handling Exceptions.

  • [ ] Restructure the docs.

History

0.0.1 (2021-03-04)

  • First release on PyPI.

0.0.5 (2021-03-21)

  • Adding sqeuclidean metric.

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

pydist2-0.0.5.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

pydist2-0.0.5-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pydist2-0.0.5.tar.gz.

File metadata

  • Download URL: pydist2-0.0.5.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pydist2-0.0.5.tar.gz
Algorithm Hash digest
SHA256 50c0bc4027754bba37302a530d2e3e9cb1de7acba63b0f629bcd5c5d7a475b76
MD5 580a88c07cb0a789252b1bc90092f744
BLAKE2b-256 7a77b3084deb7b319ee57493e6331bbe117d526448b4ab369bef64de9cf26023

See more details on using hashes here.

File details

Details for the file pydist2-0.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: pydist2-0.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pydist2-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d580c83939ab9cebb27b5be093b4356092e36f2dbd237a7a0d1e9603f23bde9
MD5 acbeb71dd802e1a8e025ccbb442126cb
BLAKE2b-256 41d674bce8fb149317b3f203e34be1aa57023e110e8a534d6bf0b5f41e20c925

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