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 Requirements Status 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 Distribution

mlprodict-0.6.1522.tar.gz (562.3 kB view details)

Uploaded Source

Built Distributions

mlprodict-0.6.1522-cp39-cp39-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.6.1522-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mlprodict-0.6.1522-cp39-cp39-macosx_10_9_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

mlprodict-0.6.1522-cp38-cp38-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.6.1522-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mlprodict-0.6.1522-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.3 MB view details)

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

mlprodict-0.6.1522-cp37-cp37m-macosx_10_9_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: mlprodict-0.6.1522.tar.gz
  • Upload date:
  • Size: 562.3 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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.6.1522.tar.gz
Algorithm Hash digest
SHA256 5d6b8aba25b7171b6e35c6b9f173afdaf323a48faeb2737c1b99e8f3bf168e7a
MD5 b3a226c1c7b9cc70424ba9a590598db0
BLAKE2b-256 a232ea7d9ecc0445a2bbc7badb4e9076324ff5e9fa88da91370cb76cd47d3c22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1522-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.9 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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.6.1522-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9547b771d8f09b6dc5d6b628cbc726bb751d1f1185d9b8e68c38cdf207922a91
MD5 9cecb338a382a9d34303e9d1fe492b45
BLAKE2b-256 1fed38287e4b3aec21695d87346d2e53f9977d6845cad17f1f0e212d1fcf1281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1522-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03b4a203dbc807dcbff7892c6b55922d10af59a99fc23e4d5557d31c179e31ab
MD5 b2a05fe0c0e79c8ed45750ec4e7e270b
BLAKE2b-256 f64c2ba10c492e677d0bbd55ebadb7be05700cf5e2de2f219bd4296c7e1304e4

See more details on using hashes here.

File details

Details for the file mlprodict-0.6.1522-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: mlprodict-0.6.1522-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.9, macOS 10.9+ 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.6.1522-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ee18726b4f6cb4e2b6d421c3668e8b83db40e6b5b0dd338de4509e63f8c0bb7e
MD5 e97680d006e547b3aa6427842d64806f
BLAKE2b-256 1776847eee423a8e1ff921d607eef1bc27437972446be0b3c44498d23a874290

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1522-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.9 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.6.1522-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1f59916dd2b69bde57190a7b500257ec9a0d63fc298d86808e86d4fac4904dbe
MD5 56d1ee90792c087790e2c2620bb2d17a
BLAKE2b-256 a652557514f668f850a7610e38dc262493cdc98c5cf00feb0153a7c2a1e07328

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1522-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7fea25db93911f8e54a208e3a2fc74ae29dbea71d03948f5e04e1c4b0c5040c5
MD5 edb41da559a3c6a872d8a06faf842399
BLAKE2b-256 477351c061e1b940a72a4f691ff9cd1cdcdfce7e13f534d6b4686685a00a1de4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1522-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f00676220085d9339f7ea8575bfbf288489bac035a52fad96572f447032bbe6
MD5 b036a98d8e2b50c0ac8dc463d36830d7
BLAKE2b-256 5bcabf261221652994e0f68afc9bfaac314dbbe199cee1f9a276eb395e0ee886

See more details on using hashes here.

File details

Details for the file mlprodict-0.6.1522-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: mlprodict-0.6.1522-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.7m, macOS 10.9+ 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.6.1522-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ebf67599588fd99500f0e85eb6fb932251c679dfa09aceb31af666573b107c40
MD5 93dd832a1de40bf12b2cb5bc7b302f34
BLAKE2b-256 42c4ddabafd56723e7ed17cb0dd51b9234fb4c1ae5e30fab3d2e735fcbeb6df8

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