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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.6.1447-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.1447-cp39-cp39-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.6.1447-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mlprodict-0.6.1447-cp38-cp38-macosx_10_9_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

mlprodict-0.6.1447-cp37-cp37m-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.7m Windows x86-64

mlprodict-0.6.1447-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.2 MB view details)

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

mlprodict-0.6.1447-cp37-cp37m-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: mlprodict-0.6.1447-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.1447-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 493ac8e6d7eeed55b8f024fa5b0abefe10418a8d3939b4b866a33bba6b04598f
MD5 40fc544619244a02945578a5186837ef
BLAKE2b-256 e96936b77656b3d234547abe4bfa1f6592bd2752579582358a9e050d647b890d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1447-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7173cd7a5a370f5f03fda689842b5f2954d7e77bdd55f9d9e70fbd379c76511
MD5 05cf0c95e87569f66e7d4bc7b279f5a7
BLAKE2b-256 16c47c0615edaaf955e45a56bdb15362dfc844aa2933e79a3fc977a931b95ce8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1447-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.7 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.1447-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d774059dbfb37b12ac240fae7dc31ba90ef769648347f8b8aea0aec4358dac8d
MD5 afb05435763b4bd6a71ba3b9751c5142
BLAKE2b-256 fcbf591276912dd277b41fc4faf8a125f66c51176c2ef7e8a1254e84f78c29c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1447-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.1447-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 375449f944453df283966031e74939f0ed6f58dd69d86b185b82fd554b959c38
MD5 ef5bcfa771af61cc3919eae5db0f5972
BLAKE2b-256 e78b182ddf94bfeaef8495b4eb5abbe0f43c10b692ef1a4c65f2c71d339d9d52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1447-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3797b8570f9f74a686328dfded7614b9c1a0a0c1910ebbad9a484737a0828132
MD5 68845aa46d0d18f186790fdd17bd38a1
BLAKE2b-256 d5d469c4f0f4b42cf1a6a01a5ce960b81555f95f2d2f492a20bb8ab5e71aa646

See more details on using hashes here.

File details

Details for the file mlprodict-0.6.1447-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: mlprodict-0.6.1447-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.8, 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.1447-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e57065f5c0041b0ba8775dd24e6ce9e9bc53c82af0b90d5f0c95ef0da0d1ca47
MD5 2e95cf818ed427997f9a0027da81f7d8
BLAKE2b-256 edd64c26f98df6150769e63bd81ed0897f31a49816a8c6268d80426ca94e187c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1447-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.9 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.6.1447-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 94508f87ac94ae9d38e7234cc07082810a9f0731411c01ee2b164da98a775901
MD5 62717ef6db1caf39018177fa413b0b44
BLAKE2b-256 73af986c64b04386d9983d27385b23ee4b5da1e622149fd6c51d70acbe570ea7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.6.1447-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3934b5c9e898222467ce54a16cd91116fb0315363cb202df44af05102b2f164
MD5 4f8e545d19083ab4f40923690df38190
BLAKE2b-256 4fc4f9247f10256cf66363b273c0ec21d15221d99bc352de1c13296738abffda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.6.1447-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.7 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.1447-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 abbe54d11bc3148670d08cef7213a30d3a23804836882d7b57736764a1a478b4
MD5 190bda7d30fafe600e00271122dfe49a
BLAKE2b-256 9e5da778445208ffc2bfe3c9bab7b4e2b6f059cc443b44a0fd5a2f738b843286

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