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.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.1697.tar.gz (637.8 kB view details)

Uploaded Source

Built Distributions

mlprodict-0.8.1697-cp39-cp39-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.8.1697-cp39-cp39-manylinux_2_24_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

mlprodict-0.8.1697-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1697-cp38-cp38-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.8.1697-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.1697-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.1697-cp37-cp37m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.8.1697-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.1697-cp36-cp36m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.8.1697-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.8 MB view details)

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

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697.tar.gz
  • Upload date:
  • Size: 637.8 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.1697.tar.gz
Algorithm Hash digest
SHA256 39fb1c662abc66f3357f4a0d09c063362d5dc06a2592f2a0593f1cbcb1135ae2
MD5 7f23150265678f889af207231a502c0c
BLAKE2b-256 bea4a6f43c756eddf828cfe1b018229b9da987df0aa70328e236d18f9bffb3eb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.1 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.1697-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ae37da03bd3fb09b27bcdd48e41c616b4df10f122c4782a561f2e2efb27f987e
MD5 7ca058e8cbd220eb5d92587feed9d010
BLAKE2b-256 2af07c4a05802aa294eddbac97126520559dc2b929444f95c8bedea2b6587e15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 16.5 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.1697-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 858033e0ce5c2dde999d6f3de8718d32cd2982ad3513ae715495db3927f9685d
MD5 03171b20621e83dcad7d5129e9092923
BLAKE2b-256 48518a5da2bd793d4024fd3202c14c017e984d66d3c72d2ddded72066b6e51a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1697-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b72f970b5bd0e3061580986d3a4a456d4b1f8cdde602d939f193924eab91d12
MD5 eeda3bf9c838ea9cc8fc9f5c89f6f32c
BLAKE2b-256 fb706a945d9d5b97851f11239cee14bdfb6374ba29f44c58719ca29419da424c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.1 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.1697-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4457561ec65f1cf0fe9c621be658f9b2533990f0954fbde892c600e5850a7190
MD5 425072b0cbbd652f84efdf143c62d16b
BLAKE2b-256 06147531d3ad9c33e5db944e59a828717e755f3aeab4381750f074d4ceeefc57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1697-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a11d667a62230d55d666bf1f07050d8b5794628af368a1a5c1203cfd5d4ad104
MD5 f303f3ccc870b429fdb6e5d9ff7dc8b5
BLAKE2b-256 ef70f5ffd9a7aa5e76008895b7b80d4ab215e0ad677586cb6f46aaecdb05c5f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-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.1697-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 54cc6d71d64bbba0dc9b605923e3f76f3233074d724cfbccde7c58b5e15c399d
MD5 82ce29f5b58fd443e38a060487103158
BLAKE2b-256 932b867649d8b9976fbe7ffb780b567a6467c475afc12472dc9d1ffd1618ddee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-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.1697-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f2a30f682ed5551a1d281b82c241d1aa414c134f5a687ad74b10a8194d636616
MD5 2d8b2f6cff0b81e74f28757c7ed086fd
BLAKE2b-256 12d4ee8b3fffb308a318e327293c7da1177e5a4e8acce024384df997f1ca952e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1697-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4dfd4779ff21b22a8a458c55d0a9767cf1ee6c77c831807d620cac3d037a337
MD5 7a1859068772ae2107d1a2ee8a12d480
BLAKE2b-256 0d560ae7ac202d4b99d8ab1862e4a484d5308c1a2a7b445789fc15eeae71c2bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1697-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.1697-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f194a154c6b714702b318bf398407f007dac79bba1f1e12ac83a73433b8090ec
MD5 a9fc44470bb841332b32ae0fc7540b51
BLAKE2b-256 f31507cbb6e4348b4cf89e05d35fc91daa2d438a85cb3e72934e6e21e9a25afe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1697-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd516a75c2aa6878e8be6b81c71e7bee6e2576078ee9345dfe4d5d959edc4d9b
MD5 72adcced2885d330d30c0140fc162863
BLAKE2b-256 ce40256bb9c05580211ae192434e5238130b977c664a63a1bc9534d8cfdb90d6

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