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.1626-cp38-cp38-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.7.1626-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.6 MB view details)

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

mlprodict-0.7.1626-cp36-cp36m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

mlprodict-0.7.1626-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.1626-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mlprodict-0.7.1626-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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.7.1626-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c6018ca4115c389c6b3831a8cb0c8083bbc3d7a3128831db1ff318091874cb24
MD5 98e98e2b242581a76fe32ca6bd3920f9
BLAKE2b-256 8c014cd8128db3b336e3cc6ea6f791aba0dd89f634eb5b607922f21f2b732265

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1626-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0b8f2b6922afc29a1ac3599b5bfb40e824d636071e53b24da41a12be43c4d30
MD5 756397d1a90aa395c4c575d98d7cdbae
BLAKE2b-256 6f547cda4be5432906d2e6d2986a408a6174c2a520413409d27b9443b9393e54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1626-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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.7.1626-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1a0bcd1d48255c0a52e69d13c0d620f3ea8ce2781c3ec12352337c8d5d73b96e
MD5 9e93a868ffa2ca5fa1db24d2d5cc88a0
BLAKE2b-256 728cc89221c46db561cdb8f9d2462f4fc706426419e3b1dc08e98c8e4f274373

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1626-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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.7.1626-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 160f70afe5d1cdcc1bc9b7d0cac569572021569fb369c171f07124de4d009afa
MD5 6847fc4e6cc3306845b65be1155af3e6
BLAKE2b-256 4ba3b1fdb804fe72b2f787f28af45a32d2a1529f2290f28a07c6232987e0df23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1626-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86832725ea0c9886f06524a88850fcb4340e0b3e3d103301761a03744d48f073
MD5 a32cbf991eb52fe9f53ae7ac4fefbe87
BLAKE2b-256 e4c332ac9aff47adebd9b50da33144bca247d7735e7e2bcd1eb8cf26c22d3f4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1626-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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.7.1626-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 068e530785f12087960c694c1d2c036c17d326c931673ea1ed03a7f81fd59fa2
MD5 e0e9bbb7f296a127ef150ae394937802
BLAKE2b-256 42eb0848d627993dc9d6c4587bae702071d07f3ae62c14080e271f6a695532ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1626-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 417a7b51abdf4bfc3f376e4f676c5c2ceeb1a3b4cf090a6ada3ba91610632ee5
MD5 0262c0f5505f56c78089f1fb34b75151
BLAKE2b-256 f0f0490c35395d81fdf5eb7f101332befe09896829f38d85b8f6f89aabae003e

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