Skip to main content

Metric python3 module

Project description


A python wrapper for METRIC library (


You need Python 3.6+

Linux & OS X

python -m pip install metric-py -i

Windows (x64 only)

You will need to install any BLAS implementation. The easiest way is by using Miniconda:

conda config --add channels conda-forge
conda update -n base conda -y
conda install -c conda-forge libopenblas openblas -y

Then you can use pip to install

python -m pip install metric-py -i

Build from the source

git clone --recurse-submodules

Download and extract Boost (1.67+). For Windows there are pre-build binaries available.

Install Prerequisites


sudo apt-get install cmake
sudo apt-get install libboost-all-dev
sudo apt-get install libopenblas-dev


Install Miniconda. In Conda CLI initialize your virtual environment with desired Python version:

conda create --name my_env -y python=3.8
conda activate my_env

Install OpenBLAS from alternative repo

conda config --add channels conda-forge
conda update -n base conda -y
conda install -c conda-forge libopenblas openblas -y

Build package

At least 2GB of RAM is required

python bdist_wheel

to limit memory usage during build add MAKE="make -j1":

MAKE="make -j1" python3 bdist_wheel

Install module

python -m pip install dist/*


import numpy
from metric.correlation import Entropy
from metric.distance import Euclidean, P_norm, Manhatten

aent = numpy.float_([
    [5.0, 5.0],
    [2.0, 2.0],
    [3.0, 3.0],
    [5.0, 1.0],

for metric in (Euclidean, P_norm, Manhatten):
    res = Entropy(metric=metric(), p=3, k=2)(aent)
    print(f'using {metric}: {res:.5f}')

res = Entropy(p=3, k=2)(aent)
print(f'using Default: {res:.5f}')

for more examples please check examples/ folder

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

metric_py-0.0.6-cp38-cp38-win_amd64.whl (1.7 MB view hashes)

Uploaded cp38

metric_py-0.0.6-cp37-cp37m-win_amd64.whl (1.7 MB view hashes)

Uploaded cp37

metric_py-0.0.6-cp36-cp36m-win_amd64.whl (1.7 MB view hashes)

Uploaded cp36

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