Skip to main content

Metric python3 module

Project description

METRIC-PY

A python wrapper for METRIC library (https://panda.technology/de/metric)

Installation

You need Python 3.6+

Linux & OS X

python -m pip install metric-py -i https://test.pypi.org/simple/

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 https://test.pypi.org/simple/

Build from the source

git clone --recurse-submodules https://github.com/panda-official/metric

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

Install Prerequisites

Ubuntu

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

Windows

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 setup.py bdist_wheel

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

MAKE="make -j1" python3 setup.py bdist_wheel

Install module

python -m pip install dist/*

Examples

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

print("Entropies:")
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.

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 Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page