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 Distribution

mlprodict-0.7.1602.tar.gz (607.0 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

mlprodict-0.7.1602-cp39-cp39-manylinux_2_24_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

mlprodict-0.7.1602-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mlprodict-0.7.1602-cp39-cp39-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

mlprodict-0.7.1602-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.7.1602-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.1 MB view details)

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

mlprodict-0.7.1602-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.7.1602.tar.gz.

File metadata

  • Download URL: mlprodict-0.7.1602.tar.gz
  • Upload date:
  • Size: 607.0 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.7.1602.tar.gz
Algorithm Hash digest
SHA256 f812c2a750e48fd9163caa664af9ba7c19ea2cfd76a0442aa61fde358da0069e
MD5 30ccfda4a06c177e0561e992c4236309
BLAKE2b-256 4e07f61fe66e8e348cf0f5e6831c83f82d6a1ced8321906c4828e67c3b8e056c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1602-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.7.1602-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 014e9779555a6638efcdda347351356031032a02626a7173ee858c50e5c2d69d
MD5 8896529351a08aafa21fd54c50eeb48d
BLAKE2b-256 00d258eb9624e15c9c573b2ad0650d446e86a25d2b7dc8e29253f7037f566fd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1602-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 15.9 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.61.1 CPython/3.9.5

File hashes

Hashes for mlprodict-0.7.1602-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 b4c1807c2f2e9c9a9a27befdf71a53c61bd0fb1776bcc4c2646dd36c9e129a55
MD5 f46375b17276d822d71892dfcf296a40
BLAKE2b-256 8ec80ce1471580035e167c614dc89bbe6b02d752bb521bef2587c0e55a36896d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1602-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e30ba05bba5f343f9cc01b32f126a66b8b0650f7596cea879b75eb85584269a5
MD5 7b5ad355596caecb69dd6444d04fb914
BLAKE2b-256 6386f7ca67b7a230aeac9fa50f15ea5872467c86bbf656f61da41ab865d590fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1602-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.9 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.7.1602-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 14763c324506899ff95b75e47a57addeb6c459181150f28fb4e9b59c892cf2f4
MD5 5bec5bf6569892b6e4f2dd317853a5fc
BLAKE2b-256 679dd35f65f35dfda50ad71239756632775252c766aec395e7a354858809bfe0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1602-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.1602-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 be8ded142589aae44d521c7d2d040a3a0d05aa11e67bdeba4692e9f344003c01
MD5 d2d32cc042cc9a9a8f8e54acb1025ced
BLAKE2b-256 5384d5385a70522fa1219b7e54e8c94125eef20a385095829d068564558fbb5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1602-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5799505b55b982061a8ed3b643b0884b01979f22c2c589d24af0e1a1a2219f3a
MD5 8bd87c84c26645306e5b244c92e90f30
BLAKE2b-256 ed220d49d1700dbeedbadd1763b0c6909fdeac4e732bd484e098f059b067398c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlprodict-0.7.1602-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18b121c5e58b317ea03a6407efc00d05864dca26c9bd30e799b48f387044e858
MD5 49191d1d8523e672bd360cd3dbecaf5c
BLAKE2b-256 b1b637456f10213ba5deb82c63fd5746463ebe0a79858513994337f3351cc884

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlprodict-0.7.1602-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.7.1602-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 de124e735e3eaa7e720cb81ae6e999381ee07346eec3e6a63c2a22bdd4f97b5c
MD5 3d803e33ec02f7ab483c698a43509088
BLAKE2b-256 0546054e0fe2447ee2e381b04b471fc6b9c1f7154dca5605c6e4eba04e36e1c8

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