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 explores ways to productionize machine learning predictions. One approach uses ONNX and tries to implement a runtime in python / numpy or wraps onnxruntime into a single class. The package provides tools to compare predictions, to benchmark models converted with sklearn-onnx. The second approach consists in converting a pipeline directly into C and is not much developed.

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)
import numpy

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))

# Predictions with onnxruntime
oinf = OnnxInference(model_onnx, runtime='onnxruntime1')
ypred = oinf.run({'X': X[:5]})
print(ypred)

# Measuring the maximum difference.
print(measure_relative_difference(expected, 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]

Some functions used in that package may rely on features implemented in PR still pending. In that case, you should install sklearn-onnx from:

pip install git+https://github.com/xadupre/sklearn-onnx.git@jenkins

If needed, the development version should be directy installed from github:

pip install git+https://github.com/sdpython/mlprodict.git

On Linux and Windows, the package must be compiled with openmp. Full instructions to build the module and run the documentation are described in config.yml for Linux. When this project becomes more stable, it will changed to be using official releases. 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.1649-cp39-cp39-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.7.1649-cp39-cp39-manylinux_2_24_x86_64.whl (16.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

mlprodict-0.7.1649-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.7.1649-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.1649-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.1649-cp37-cp37m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.7.1649-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.1649-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.7.1649-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.7.1649-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bf20f3d95175b7b81bc9ae3c0c58b441a0d1836dde7e73be4b2110f2a969517b
MD5 625bf1658a1fb2817a6ea9829aaa239a
BLAKE2b-256 d12ce60d9163ab4f479a4fffeeb4e0cc7e47b0ed08979674e251acf772702ed3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1649-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 16.3 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.7.1649-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 375c5bc09662b3a2f881b046b34a138846c957145930ec85e5127ed1a58bd62a
MD5 f6c574b03c705ce9d66fb8c11f90ce0d
BLAKE2b-256 9b9cc67cb4eba75fb7ff297a8b867597fcfdb8e324d1a0fc3d417f1ebf23d5d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1649-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 050016e6f2218f3aa856b7318ed0594d13216a800328a61c35777850758018a4
MD5 038380fea1718a3ece0ee82ee9749d34
BLAKE2b-256 2456f2ca757aaa97ead1ff420a4b559ba8516cda8e9ffb2a9304346006da44e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1649-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.1649-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 547b90eb1cc2984579afed4ba0acbde1a120f7caa6980dafb927809ed2b61903
MD5 26a0ca768095a7a380c7905e80a2e50b
BLAKE2b-256 28200e9dd8c270ab29d6d7aa59cc0f7693d97b006ba07d724c364c01dcee8682

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1649-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2eb3d8da55b654e6fc5283d105f239ca91e919bcb089fa5193281a385251480f
MD5 6b2b2699c0e45fade9025b83b8f134d7
BLAKE2b-256 a9c802abb99730c2f6a16fcea5938a67c33dd3a40ac2cf4e9730d8320d75bd39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1649-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.1649-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 35e4dd1679cca7b32d6d63f9f160f0326e518ea2da312c995f8af3ec431a48eb
MD5 ac0b4849cd2f679a96a4d5cc8405bece
BLAKE2b-256 641ab52888168c7fe68157e67a4ab04951370df680b13368d3e13b19718c5cca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1649-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.1649-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 bd265c7d7a96909f5790f798aa58f9dcedf5fac730d6616d5e08f3b3d25466ca
MD5 b63086b13daec56dffed848f0fde3ec4
BLAKE2b-256 664fd5edbc4ed5c7d92111daf503029cd06bf6ac14dcd91055ba0c4e76bfcc6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1649-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd17cd9a5bc45ca35779c26fea4d340168eaf03647644170df7f0352db6b2da3
MD5 ab3b06c2adf0669596edf439d2e2394a
BLAKE2b-256 e3437499e35db1d8898ccd47ed0557bb994f9d7014e8a8819bf34f0a9fc9882a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1649-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.1649-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1331d1e372b9f78d2eff2d558e76088e6ec1ae549328394d23056377f42040dc
MD5 28f8dfe17c6d98e6364ad46efd3b8210
BLAKE2b-256 7cdf032f5be3d8dc4cd27f0da5c91fa630b4df4cb3e6a11a5b3274e1a3b34e08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1649-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 179900351b288d21dc4dd92bbd2addea3ea06dca34e28843054db9d8388743c4
MD5 7aadd654b7f306a35a1283f4e5df2406
BLAKE2b-256 bf0f612531f0c219561a4b3967d08dcf9fddee0116bcb0abe912614feeaa09e2

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