Python Runtime for ONNX models, other helpers to convert machine learned models in C++.
Project description
mlprodict
mlprodict was initially started to help implementing converters to ONNX. The main feature is a python runtime for ONNX. It gives feedback when the execution fails. The package provides tools to compare predictions, to benchmark models converted with sklearn-onnx.
import numpy 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 from mlprodict.tools import get_ir_version_from_onnx 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), black_op={'LinearRegressor'}) print("ONNX:", str(model_onnx)[:200] + "\n...") # Predictions with onnxruntime model_onnx.ir_version = get_ir_version_from_onnx() oinf = OnnxInference(model_onnx, runtime='onnxruntime1') ypred = oinf.run({'X': X[:5].astype(numpy.float32)}) print("ONNX output:", ypred) # Measuring the maximum difference. print("max abs diff:", measure_relative_difference(expected, ypred['variable'])) # And the python runtime oinf = OnnxInference(model_onnx, runtime='python') ypred = oinf.run({'X': X[:5].astype(numpy.float32)}, verbose=1, fLOG=print) print("ONNX output:", 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]
The code is available at GitHub/mlprodict and has online documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mlprodict-0.8.1674-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de29c36e6c4192849f80550667afff72df4280f11ee710512c4780c347d3bf2a |
|
MD5 | 651d21484b1ec0e2b856cd71d4c731ee |
|
BLAKE2b-256 | 2a47df82e334bd8bfc87e056de582b779d85b6593364d35343d396021848dde0 |
Hashes for mlprodict-0.8.1674-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4df651633cfd212f4dc222c165cc70863e4f594d1fab40ebc8b999c89dde732b |
|
MD5 | 948d329dbefdb998c1ec33c58f91f5dd |
|
BLAKE2b-256 | e8fa562f68123abc8d010eb695e54f0061c6f87fcac2fb482bda40d1b4881c64 |
Hashes for mlprodict-0.8.1674-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e8b025aff7139f66227f5463897c8f354f068c013533848711bb799270485c7 |
|
MD5 | 00216188e6960702546cd98bbda6722b |
|
BLAKE2b-256 | e8f6ff74e6bfff800559037a23901cac057791a29e1e6d8e517dac33e367673b |
Hashes for mlprodict-0.8.1674-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e157347f7241b8d67a050b01e6519e6c9260baa74a480de54b74275571301f46 |
|
MD5 | ad5c8bf293e02404bb8849475bb63100 |
|
BLAKE2b-256 | 28f298396032adae4b19f0909e8f2f36228b0979c0b749d2c9988602e4243f93 |
Hashes for mlprodict-0.8.1674-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57ff0d6cdf0346223114568af8d2195e1146fca56b47600afeaa4ecf1ef3698e |
|
MD5 | db97c29c7234fbed617cd610368ad8c8 |
|
BLAKE2b-256 | be24299a00c07b2d9482a34178a5625f107f494179bd783600c7c6364aa45f0e |
Hashes for mlprodict-0.8.1674-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d8ff50c071d6a77b22a9b29081fd9d9c56973755a79683d5c503191c1b65cb0 |
|
MD5 | 5fbae17eba2b919d477c009f5f5f9797 |
|
BLAKE2b-256 | 4a97f4dcc20f65c99cadc56e161ed63e88166ddfd98cfc6fa8a121f72a04ff8d |
Hashes for mlprodict-0.8.1674-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1b6574a49a8f3591d5f51e920d05928f4aa523e8a8632b192626410587d576f |
|
MD5 | 1d31dadecc3d429398d8aed252577016 |
|
BLAKE2b-256 | d96251a90622fa040ff2f1357f1583f90f31edb4f1d8b86f272bf8bcad9a2e4f |
Hashes for mlprodict-0.8.1674-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b9aa72472b25cb5e305b8c935c31bd8bbbf0905426fd5444f204b4a40c1b62 |
|
MD5 | d7b44e74bf106143602927369992f0a4 |
|
BLAKE2b-256 | 00917627e2eaafec625a69719893412a315ad670f836433142e1cdfd16232c2d |
Hashes for mlprodict-0.8.1674-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52351091fe3e85a58608ae6fb0da8112ce6529651c90a6d1a20a16cc20a1f4d0 |
|
MD5 | 07fb6b189f9f578abc623e56b9f87846 |
|
BLAKE2b-256 | 5aa3de638e59f7580a599b66c7a5602c7a5320b1613bf5cbcd1e1c2cf31185b9 |
Hashes for mlprodict-0.8.1674-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d54be0e12fa24484813861b6c3ae5b84ae710deceb66a2c5b7404cdcdf28554 |
|
MD5 | df2d8d1e8cc7cb1097a02e7fd240011a |
|
BLAKE2b-256 | 510e19286548d95f8a393fd65bcd70c570abde002b3934973f298e1417eec4f2 |