Skip to main content

Python Runtime for ONNX models, other helpers to convert machine learned models in C++.

Project description

https://github.com/sdpython/mlprodict/blob/master/_doc/sphinxdoc/source/phdoc_static/project_ico.png?raw=true

mlprodict

Build status Build Status Windows https://circleci.com/gh/sdpython/mlprodict/tree/master.svg?style=svg https://dev.azure.com/xavierdupre3/mlprodict/_apis/build/status/sdpython.mlprodict https://badge.fury.io/py/mlprodict.svg MIT License https://codecov.io/github/sdpython/mlprodict/coverage.svg?branch=master GitHub Issues Notebook Coverage Downloads Forks Stars https://mybinder.org/badge_logo.svg size

mlprodict was initially started to help implementing converters to ONNX. The main features is a python runtime for ONNX (class OnnxInference), visualization tools (see Visualization), and a numpy API for ONNX). The package also provides tools to compare predictions, to benchmark models converted with sklearn-onnx.

import numpy
from sklearn.linear_model import LinearRegression
from sklearn.datasets import load_iris
from mlprodict.onnxrt import OnnxInference
from mlprodict.onnxrt.validate.validate_difference import measure_relative_difference
from mlprodict import __max_supported_opset__, get_ir_version

iris = load_iris()
X = iris.data[:, :2]
y = iris.target
lr = LinearRegression()
lr.fit(X, y)

# Predictions with scikit-learn.
expected = lr.predict(X[:5])
print(expected)

# Conversion into ONNX.
from mlprodict.onnx_conv import to_onnx
model_onnx = to_onnx(lr, X.astype(numpy.float32),
                     black_op={'LinearRegressor'},
                     target_opset=__max_supported_opset__)
print("ONNX:", str(model_onnx)[:200] + "\n...")

# Predictions with onnxruntime
model_onnx.ir_version = get_ir_version(__max_supported_opset__)
oinf = OnnxInference(model_onnx, runtime='onnxruntime1')
ypred = oinf.run({'X': X[:5].astype(numpy.float32)})
print("ONNX output:", ypred)

# Measuring the maximum difference.
print("max abs diff:", measure_relative_difference(expected, ypred['variable']))

# And the python runtime
oinf = OnnxInference(model_onnx, runtime='python')
ypred = oinf.run({'X': X[:5].astype(numpy.float32)},
                 verbose=1, fLOG=print)
print("ONNX output:", ypred)

Installation

Installation from pip should work unless you need the latest development features.

pip install mlprodict

The package includes a runtime for ONNX. That’s why there is a limited number of dependencies. However, some features relies on sklearn-onnx, onnxruntime, scikit-learn. They can be installed with the following instructions:

pip install mlprodict[all]

The code is available at GitHub/mlprodict and has online documentation.

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

mlprodict-0.8.1826.tar.gz (746.6 kB view details)

Uploaded Source

Built Distributions

mlprodict-0.8.1826-cp39-cp39-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.8.1826-cp39-cp39-manylinux_2_24_x86_64.whl (19.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

mlprodict-0.8.1826-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1826-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.8.1826-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1826-cp38-cp38-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

mlprodict-0.8.1826-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.8.1826-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.7 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1826-cp36-cp36m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.8.1826-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.8 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

File details

Details for the file mlprodict-0.8.1826.tar.gz.

File metadata

  • Download URL: mlprodict-0.8.1826.tar.gz
  • Upload date:
  • Size: 746.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826.tar.gz
Algorithm Hash digest
SHA256 00e4d21d6502b4e3642d825e275b947d162615cc7137fec68908c7c64404b503
MD5 8956d2c28e56f2e4c8f71c9ac63de779
BLAKE2b-256 1a9897b8fdf9425a948bdd1822458374b1975ab0eb59f50a57c9dd4e0575629a

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bfd367c062025a043f1bcc9daa13078195f18a06677279e71f7d8561a0ec6134
MD5 abf360bf24bd02e5f23044ff7f8bda06
BLAKE2b-256 820343e022eecdffe78a2a2b380329c425d8875a067947d18c4bc22a593fd8cc

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 19.9 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 7ccece4d9696ac570d9e17cd286ab03dc719d3ef4333021157c490a56894ea71
MD5 55901dfadaeb06c06ac04d991128a21f
BLAKE2b-256 569338b18696e7ee021dd93ff9a0e84d6a5b2d7b18e5d399a09a671b9a505aa0

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlprodict-0.8.1826-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 586d5f825d1d851b009f1651fc68e6cc53810c3b9041cc596052bb9a84575412
MD5 973f9759497546c0170d6788d50e1ba6
BLAKE2b-256 4a0f7f3055ad06bb5ba97b3cab956612796eeb387a31df56ed0dad5ae544cb8d

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d08a4847353761a55d27bf4a429b3064dca176fdbd6176d75ca650b0d70b38b2
MD5 37d7a5cab052f52937212d190f2369ac
BLAKE2b-256 830999455410109d0bdc96a5e7275378f08260674d2e13a70752f2d78cb396f5

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlprodict-0.8.1826-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86fa28255821cbca650a18c46a25fcf2ed496911aaa7f2eb97db561cee74f6f6
MD5 17f4e227b4c901037df9ee36da1c2d4a
BLAKE2b-256 ea8d7d3e2c6ddce9a1f2226de8b810ddcab5acbcd2e5f43c3d146a70db92986b

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 96fe3aefe39bb287fee4ba2b49e537800fe1faf20dcfc130fa468321e9747658
MD5 83b59667b9f0ed794f7438c0a63411f4
BLAKE2b-256 0e259d85f91ea145093137c0a7a65ce6a5ec5c0bfa8240bd214af2a733c3927a

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 bf04410b48677878a271ee431ca5596b5c76bd75f837bc8317200dc5c2b1419e
MD5 ea3eb6fad0858bae17ccd8c4c45be797
BLAKE2b-256 5130c07afd3e7d7ac7e4e6b1ae1cc86b8fb9c25281eecf7da97d153bb0c404a4

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlprodict-0.8.1826-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5dc5abccfee69cb7a7ed5c5aa2fb0fd658bad38737e452ae3dc69a5ebd9df64a
MD5 171e809d7300b1c01107fac07bbeb267
BLAKE2b-256 e5510d8e2d6597daf8882c2104fcebdc75b488aedc471a418cf75ff3baf78fa5

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.8.1826-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.11.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for mlprodict-0.8.1826-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b67f7f8d0d0419bcfa5d412d2563d87676fa521ca4f7877481b125864cf764de
MD5 32166e98744087bd582564edef59d78f
BLAKE2b-256 61ebbb7a27b37f444ea9f6ebb5b08b525d73de26c653764954a181dfb75a0281

See more details on using hashes here.

File details

Details for the file mlprodict-0.8.1826-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlprodict-0.8.1826-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a39cef79a77cddb21713075c84d15e938e98dd879fcf6e91fb14cda0800a7c03
MD5 8b28982148f2ad55e021180bf934afa2
BLAKE2b-256 c91c0dd7c75bb2b845284fc4eef5fec1f9f2131bc4a92f73bfcf2710c8d210d2

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