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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.8.1762-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.1762-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.1762-cp38-cp38-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.8.1762-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mlprodict-0.8.1762-cp38-cp38-macosx_10_13_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.8.1762-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.8 MB view details)

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

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

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.8.1762-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.1762.tar.gz.

File metadata

  • Download URL: mlprodict-0.8.1762.tar.gz
  • Upload date:
  • Size: 674.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.1762.tar.gz
Algorithm Hash digest
SHA256 bea58815fe161d2c6692551f13c4bedc486af8f3849fb488613e690bd8226234
MD5 ef7afe0a50aabbac74dc000312d002c4
BLAKE2b-256 2b8eb7998faf602b213a3520c63ba57e61b39794154e694b38947cd5c9cc5b28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-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.1762-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9ff2b566626c358732717d49b4463541b12b5019d90826ac10c13e3ca7705dd5
MD5 571cec7eb443ba7a6bac6406dc5f80d8
BLAKE2b-256 3df5ffb40cde5a4eda563ff979697bddcf021b122bbbad5fc0653eb2c37b738d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-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.1762-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 2508f93d05a8d095c6503f483325e6fb26eeeba9f2a576d33703382f20270bed
MD5 4737cd0e22f81008ead8929cb4f9d172
BLAKE2b-256 2c695105cfecdc64c9e7bc51b3ac95f33f3dc2c762f4f895ca13b2543c0d221b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1762-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d94fd96deeb485df83099fd766b7e570ef472b6cb1718ad7f59311a4b66c0cd
MD5 1e30451a19393f52068b922e4ef8ab71
BLAKE2b-256 76c96a5cd05d4dccf8f3637b22e5ba585fbf09a01ea3c058bc4458086991850d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-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.1762-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3b95a4a85fc718b023510ad7969f6239b895ab5cfe3b8d329cb7f80e22c19409
MD5 92455c3cd7b4bdd86a8a2aa316018e11
BLAKE2b-256 c32bbc22f6ff91e6b76c40ce2c2eec4217082e48aa757800eaf60a5eec0e71fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1762-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d0bc3f8614628e85888d61514332ec354815afdd292fd704819465f35c4a15a
MD5 dc9267787da5fd5441e968968e89e983
BLAKE2b-256 e9192baeafaea7ef2a72009202f0a0215f9600688ea40913167db0f282a5e495

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.0 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.1762-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9f3172280271a112dbd5121e0a7149aeaa2eff626514241d986f2131ba3cd3ac
MD5 fa61b2cdd17d213c7e747387908b6e12
BLAKE2b-256 21447e200496adb55516a1053bc818a9a3026d9884c930c981fe317828eb7642

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-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.1762-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0ada56be2b98c22c2fc19675b0157b5d3d003f87abfbd11e542f832abe6f8fe7
MD5 ff452077844f6e7ee17a3bf9a7324d7a
BLAKE2b-256 cea9f8479d5c057b066f6317fbf83f694c3df0668ffc7f1d88b280f514281f5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1762-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 691d7da7867fb1df5bebfd0e247fa9d299ba2cb14b12213c90a605578f49f452
MD5 39780ff5880bcb164052455ef1e5befc
BLAKE2b-256 7297678bbf2d76b76a666d90bd197bddfae19beb1f44cf0ab76baf09e071699d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.8.1762-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.1762-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e510e1618543eccd5ecb4cb0903851b0d35a50a7754b63ce8fde8ad3dee645e0
MD5 c442bee103bb3f73f24d0970b5a32e2b
BLAKE2b-256 85a9f57d498ac24a837057e417664b354d4d1c54f87a74f870e65d56068bde63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.8.1762-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6edad4ba422451776085ecf73eb0082c256bedb32f1421d6385338d1f9c1e324
MD5 b88f0427756ec8f019ea253744ea89ef
BLAKE2b-256 0d6526e4e8da929a17d894bfde569d7b603a2831bc5c304494f189ae8e067d14

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