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 feature is a python runtime for ONNX. It gives feedback when the execution fails. The package 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.tools import get_ir_version_from_onnx

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'})
print("ONNX:", str(model_onnx)[:200] + "\n...")

# Predictions with onnxruntime
model_onnx.ir_version = get_ir_version_from_onnx()
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.1674.tar.gz (632.5 kB view details)

Uploaded Source

Built Distributions

mlprodict-0.8.1674-cp39-cp39-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.8.1674-cp39-cp39-manylinux_2_24_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

mlprodict-0.8.1674-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1674-cp38-cp38-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.8.1674-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1674-cp38-cp38-macosx_10_13_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

mlprodict-0.8.1674-cp37-cp37m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.8.1674-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.7 MB view details)

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

mlprodict-0.8.1674-cp36-cp36m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.8.1674-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.7 MB view details)

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

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674.tar.gz
  • Upload date:
  • Size: 632.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674.tar.gz
Algorithm Hash digest
SHA256 52728070cddf1bb0b92e10f604b24ed76320559932e7c6628c4ba11a6b95e22d
MD5 9a958a4a0be431f19c5b661146ec3b49
BLAKE2b-256 eb1f7c68375e3127aeb30ab1d6583ed533fe6db901ef9597a65fb1409516d6cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 de29c36e6c4192849f80550667afff72df4280f11ee710512c4780c347d3bf2a
MD5 651d21484b1ec0e2b856cd71d4c731ee
BLAKE2b-256 2a47df82e334bd8bfc87e056de582b779d85b6593364d35343d396021848dde0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 16.4 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.6.1 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.1674-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 4df651633cfd212f4dc222c165cc70863e4f594d1fab40ebc8b999c89dde732b
MD5 948d329dbefdb998c1ec33c58f91f5dd
BLAKE2b-256 e8fa562f68123abc8d010eb695e54f0061c6f87fcac2fb482bda40d1b4881c64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1674-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e8b025aff7139f66227f5463897c8f354f068c013533848711bb799270485c7
MD5 00216188e6960702546cd98bbda6722b
BLAKE2b-256 e8f6ff74e6bfff800559037a23901cac057791a29e1e6d8e517dac33e367673b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e157347f7241b8d67a050b01e6519e6c9260baa74a480de54b74275571301f46
MD5 ad5c8bf293e02404bb8849475bb63100
BLAKE2b-256 28f298396032adae4b19f0909e8f2f36228b0979c0b749d2c9988602e4243f93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1674-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57ff0d6cdf0346223114568af8d2195e1146fca56b47600afeaa4ecf1ef3698e
MD5 db97c29c7234fbed617cd610368ad8c8
BLAKE2b-256 be24299a00c07b2d9482a34178a5625f107f494179bd783600c7c6364aa45f0e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4d8ff50c071d6a77b22a9b29081fd9d9c56973755a79683d5c503191c1b65cb0
MD5 5fbae17eba2b919d477c009f5f5f9797
BLAKE2b-256 4a97f4dcc20f65c99cadc56e161ed63e88166ddfd98cfc6fa8a121f72a04ff8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d1b6574a49a8f3591d5f51e920d05928f4aa523e8a8632b192626410587d576f
MD5 1d31dadecc3d429398d8aed252577016
BLAKE2b-256 d96251a90622fa040ff2f1357f1583f90f31edb4f1d8b86f272bf8bcad9a2e4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1674-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3b9aa72472b25cb5e305b8c935c31bd8bbbf0905426fd5444f204b4a40c1b62
MD5 d7b44e74bf106143602927369992f0a4
BLAKE2b-256 00917627e2eaafec625a69719893412a315ad670f836433142e1cdfd16232c2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1674-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 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.1674-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 52351091fe3e85a58608ae6fb0da8112ce6529651c90a6d1a20a16cc20a1f4d0
MD5 07fb6b189f9f578abc623e56b9f87846
BLAKE2b-256 5aa3de638e59f7580a599b66c7a5602c7a5320b1613bf5cbcd1e1c2cf31185b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1674-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d54be0e12fa24484813861b6c3ae5b84ae710deceb66a2c5b7404cdcdf28554
MD5 df2d8d1e8cc7cb1097a02e7fd240011a
BLAKE2b-256 510e19286548d95f8a393fd65bcd70c570abde002b3934973f298e1417eec4f2

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