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

Project details


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 CPython 3.8 Windows x86-64

metric_py-0.0.6-cp38-cp38-manylinux2014_x86_64.whl (12.7 MB view hashes)

Uploaded CPython 3.8

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

Uploaded CPython 3.7m Windows x86-64

metric_py-0.0.6-cp37-cp37m-manylinux2014_x86_64.whl (12.7 MB view hashes)

Uploaded CPython 3.7m

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

Uploaded CPython 3.6m Windows x86-64

metric_py-0.0.6-cp36-cp36m-manylinux2014_x86_64.whl (12.7 MB view hashes)

Uploaded CPython 3.6m

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