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 Distributions

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

Built Distributions

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

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.7.1672-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 macOS 10.13+ x86-64

mlprodict-0.7.1672-cp37-cp37m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.7.1672-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.7.1672-cp36-cp36m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.7.1672-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.6 MB view details)

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

File details

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

File metadata

  • Download URL: mlprodict-0.7.1672-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.7.1672-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e46a3440cfcd69a0bda8189eb5e26ff240b8315be88c1ac772dbcf9ca2c7d7e0
MD5 513ddc7ff7370897e9804d8d4b966728
BLAKE2b-256 31c1490b30f848f518195c48df7fdbc761f94dce33a3b8e9a9b2c7bebc36e565

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1672-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7680ae9af1cf4c3bb6dcae5f14f9c18a33b8d24d90ca971a2e796c788c184c7
MD5 26568fc37fe467963108f73a6d5ed003
BLAKE2b-256 6e44bae2ddef1a2c2c2fdcb4eb76e81e0fe6cb22a7c06ca2dad6e75d985b141e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1672-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.7.1672-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f7351f97cca0dd2d33c5f4e8efbd255417690ceb8b87bc931fbd6117c8da4cc5
MD5 a1773ed6720b675996531af75706fd4c
BLAKE2b-256 2b62f552f2160d0bfcfd5b232bd655a24d0932f6f83ce9d6996ffc2dd5f5a398

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1672-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.0 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.7.1672-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4b4391c2eb29f9180d33c73b0ea283bdc176906a20d0334244b0979c1ec46ce7
MD5 2033b787f1b96ac9ad628b0bcd7694bf
BLAKE2b-256 c209dc8e611c471ca8f48a133d448408bf0ce0bbed598fa7b1193d5a94799275

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1672-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd2e5564d24951f25ae3d1f9281393c9c3370a9be66ee3264a10e448b79ac262
MD5 79896f7f21c733a6bd19dbc6bbef9225
BLAKE2b-256 50f4f17d998fafd702081aa11f9ffc6be47102fca2655add121197751adc34de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1672-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.0 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.7.1672-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a8e83eb3c4defa1416290cb033b379282e8a1e7d5a42cc196d67f753cdc8085a
MD5 219e1420082241c26a3afe485cfa5fbf
BLAKE2b-256 022f790bfe65552348cbd7cefaa0af52edf592c827f2cae362aaeb22b35eed27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1672-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f3fb243b7f4e6bae40d19394914c003aee108060cd52d07f8a9634d338436d3
MD5 716566875472bdee8adb4b98c9463d4a
BLAKE2b-256 c632956bdefd14e0c1da1df392611ea4de3dad7bafec21ad7e172599d26884bc

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