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 features is a python runtime for ONNX (class OnnxInference), visualization tools (see Visualization), and a numpy API for ONNX). The package also 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.1697-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae37da03bd3fb09b27bcdd48e41c616b4df10f122c4782a561f2e2efb27f987e |
|
MD5 | 7ca058e8cbd220eb5d92587feed9d010 |
|
BLAKE2b-256 | 2af07c4a05802aa294eddbac97126520559dc2b929444f95c8bedea2b6587e15 |
Hashes for mlprodict-0.8.1697-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 858033e0ce5c2dde999d6f3de8718d32cd2982ad3513ae715495db3927f9685d |
|
MD5 | 03171b20621e83dcad7d5129e9092923 |
|
BLAKE2b-256 | 48518a5da2bd793d4024fd3202c14c017e984d66d3c72d2ddded72066b6e51a6 |
Hashes for mlprodict-0.8.1697-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b72f970b5bd0e3061580986d3a4a456d4b1f8cdde602d939f193924eab91d12 |
|
MD5 | eeda3bf9c838ea9cc8fc9f5c89f6f32c |
|
BLAKE2b-256 | fb706a945d9d5b97851f11239cee14bdfb6374ba29f44c58719ca29419da424c |
Hashes for mlprodict-0.8.1697-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4457561ec65f1cf0fe9c621be658f9b2533990f0954fbde892c600e5850a7190 |
|
MD5 | 425072b0cbbd652f84efdf143c62d16b |
|
BLAKE2b-256 | 06147531d3ad9c33e5db944e59a828717e755f3aeab4381750f074d4ceeefc57 |
Hashes for mlprodict-0.8.1697-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a11d667a62230d55d666bf1f07050d8b5794628af368a1a5c1203cfd5d4ad104 |
|
MD5 | f303f3ccc870b429fdb6e5d9ff7dc8b5 |
|
BLAKE2b-256 | ef70f5ffd9a7aa5e76008895b7b80d4ab215e0ad677586cb6f46aaecdb05c5f4 |
Hashes for mlprodict-0.8.1697-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54cc6d71d64bbba0dc9b605923e3f76f3233074d724cfbccde7c58b5e15c399d |
|
MD5 | 82ce29f5b58fd443e38a060487103158 |
|
BLAKE2b-256 | 932b867649d8b9976fbe7ffb780b567a6467c475afc12472dc9d1ffd1618ddee |
Hashes for mlprodict-0.8.1697-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2a30f682ed5551a1d281b82c241d1aa414c134f5a687ad74b10a8194d636616 |
|
MD5 | 2d8b2f6cff0b81e74f28757c7ed086fd |
|
BLAKE2b-256 | 12d4ee8b3fffb308a318e327293c7da1177e5a4e8acce024384df997f1ca952e |
Hashes for mlprodict-0.8.1697-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4dfd4779ff21b22a8a458c55d0a9767cf1ee6c77c831807d620cac3d037a337 |
|
MD5 | 7a1859068772ae2107d1a2ee8a12d480 |
|
BLAKE2b-256 | 0d560ae7ac202d4b99d8ab1862e4a484d5308c1a2a7b445789fc15eeae71c2bb |
Hashes for mlprodict-0.8.1697-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f194a154c6b714702b318bf398407f007dac79bba1f1e12ac83a73433b8090ec |
|
MD5 | a9fc44470bb841332b32ae0fc7540b51 |
|
BLAKE2b-256 | f31507cbb6e4348b4cf89e05d35fc91daa2d438a85cb3e72934e6e21e9a25afe |
Hashes for mlprodict-0.8.1697-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd516a75c2aa6878e8be6b81c71e7bee6e2576078ee9345dfe4d5d959edc4d9b |
|
MD5 | 72adcced2885d330d30c0140fc162863 |
|
BLAKE2b-256 | ce40256bb9c05580211ae192434e5238130b977c664a63a1bc9534d8cfdb90d6 |