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 import __max_supported_opset__, get_ir_version 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'}, target_opset=__max_supported_opset__) print("ONNX:", str(model_onnx)[:200] + "\n...") # Predictions with onnxruntime model_onnx.ir_version = get_ir_version(__max_supported_opset__) 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.1762-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ff2b566626c358732717d49b4463541b12b5019d90826ac10c13e3ca7705dd5 |
|
MD5 | 571cec7eb443ba7a6bac6406dc5f80d8 |
|
BLAKE2b-256 | 3df5ffb40cde5a4eda563ff979697bddcf021b122bbbad5fc0653eb2c37b738d |
Hashes for mlprodict-0.8.1762-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2508f93d05a8d095c6503f483325e6fb26eeeba9f2a576d33703382f20270bed |
|
MD5 | 4737cd0e22f81008ead8929cb4f9d172 |
|
BLAKE2b-256 | 2c695105cfecdc64c9e7bc51b3ac95f33f3dc2c762f4f895ca13b2543c0d221b |
Hashes for mlprodict-0.8.1762-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d94fd96deeb485df83099fd766b7e570ef472b6cb1718ad7f59311a4b66c0cd |
|
MD5 | 1e30451a19393f52068b922e4ef8ab71 |
|
BLAKE2b-256 | 76c96a5cd05d4dccf8f3637b22e5ba585fbf09a01ea3c058bc4458086991850d |
Hashes for mlprodict-0.8.1762-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b95a4a85fc718b023510ad7969f6239b895ab5cfe3b8d329cb7f80e22c19409 |
|
MD5 | 92455c3cd7b4bdd86a8a2aa316018e11 |
|
BLAKE2b-256 | c32bbc22f6ff91e6b76c40ce2c2eec4217082e48aa757800eaf60a5eec0e71fb |
Hashes for mlprodict-0.8.1762-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0bc3f8614628e85888d61514332ec354815afdd292fd704819465f35c4a15a |
|
MD5 | dc9267787da5fd5441e968968e89e983 |
|
BLAKE2b-256 | e9192baeafaea7ef2a72009202f0a0215f9600688ea40913167db0f282a5e495 |
Hashes for mlprodict-0.8.1762-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3172280271a112dbd5121e0a7149aeaa2eff626514241d986f2131ba3cd3ac |
|
MD5 | fa61b2cdd17d213c7e747387908b6e12 |
|
BLAKE2b-256 | 21447e200496adb55516a1053bc818a9a3026d9884c930c981fe317828eb7642 |
Hashes for mlprodict-0.8.1762-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ada56be2b98c22c2fc19675b0157b5d3d003f87abfbd11e542f832abe6f8fe7 |
|
MD5 | ff452077844f6e7ee17a3bf9a7324d7a |
|
BLAKE2b-256 | cea9f8479d5c057b066f6317fbf83f694c3df0668ffc7f1d88b280f514281f5c |
Hashes for mlprodict-0.8.1762-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 691d7da7867fb1df5bebfd0e247fa9d299ba2cb14b12213c90a605578f49f452 |
|
MD5 | 39780ff5880bcb164052455ef1e5befc |
|
BLAKE2b-256 | 7297678bbf2d76b76a666d90bd197bddfae19beb1f44cf0ab76baf09e071699d |
Hashes for mlprodict-0.8.1762-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e510e1618543eccd5ecb4cb0903851b0d35a50a7754b63ce8fde8ad3dee645e0 |
|
MD5 | c442bee103bb3f73f24d0970b5a32e2b |
|
BLAKE2b-256 | 85a9f57d498ac24a837057e417664b354d4d1c54f87a74f870e65d56068bde63 |
Hashes for mlprodict-0.8.1762-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6edad4ba422451776085ecf73eb0082c256bedb32f1421d6385338d1f9c1e324 |
|
MD5 | b88f0427756ec8f019ea253744ea89ef |
|
BLAKE2b-256 | 0d6526e4e8da929a17d894bfde569d7b603a2831bc5c304494f189ae8e067d14 |