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.1826-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfd367c062025a043f1bcc9daa13078195f18a06677279e71f7d8561a0ec6134 |
|
MD5 | abf360bf24bd02e5f23044ff7f8bda06 |
|
BLAKE2b-256 | 820343e022eecdffe78a2a2b380329c425d8875a067947d18c4bc22a593fd8cc |
Hashes for mlprodict-0.8.1826-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ccece4d9696ac570d9e17cd286ab03dc719d3ef4333021157c490a56894ea71 |
|
MD5 | 55901dfadaeb06c06ac04d991128a21f |
|
BLAKE2b-256 | 569338b18696e7ee021dd93ff9a0e84d6a5b2d7b18e5d399a09a671b9a505aa0 |
Hashes for mlprodict-0.8.1826-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 586d5f825d1d851b009f1651fc68e6cc53810c3b9041cc596052bb9a84575412 |
|
MD5 | 973f9759497546c0170d6788d50e1ba6 |
|
BLAKE2b-256 | 4a0f7f3055ad06bb5ba97b3cab956612796eeb387a31df56ed0dad5ae544cb8d |
Hashes for mlprodict-0.8.1826-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08a4847353761a55d27bf4a429b3064dca176fdbd6176d75ca650b0d70b38b2 |
|
MD5 | 37d7a5cab052f52937212d190f2369ac |
|
BLAKE2b-256 | 830999455410109d0bdc96a5e7275378f08260674d2e13a70752f2d78cb396f5 |
Hashes for mlprodict-0.8.1826-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86fa28255821cbca650a18c46a25fcf2ed496911aaa7f2eb97db561cee74f6f6 |
|
MD5 | 17f4e227b4c901037df9ee36da1c2d4a |
|
BLAKE2b-256 | ea8d7d3e2c6ddce9a1f2226de8b810ddcab5acbcd2e5f43c3d146a70db92986b |
Hashes for mlprodict-0.8.1826-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96fe3aefe39bb287fee4ba2b49e537800fe1faf20dcfc130fa468321e9747658 |
|
MD5 | 83b59667b9f0ed794f7438c0a63411f4 |
|
BLAKE2b-256 | 0e259d85f91ea145093137c0a7a65ce6a5ec5c0bfa8240bd214af2a733c3927a |
Hashes for mlprodict-0.8.1826-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf04410b48677878a271ee431ca5596b5c76bd75f837bc8317200dc5c2b1419e |
|
MD5 | ea3eb6fad0858bae17ccd8c4c45be797 |
|
BLAKE2b-256 | 5130c07afd3e7d7ac7e4e6b1ae1cc86b8fb9c25281eecf7da97d153bb0c404a4 |
Hashes for mlprodict-0.8.1826-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc5abccfee69cb7a7ed5c5aa2fb0fd658bad38737e452ae3dc69a5ebd9df64a |
|
MD5 | 171e809d7300b1c01107fac07bbeb267 |
|
BLAKE2b-256 | e5510d8e2d6597daf8882c2104fcebdc75b488aedc471a418cf75ff3baf78fa5 |
Hashes for mlprodict-0.8.1826-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67f7f8d0d0419bcfa5d412d2563d87676fa521ca4f7877481b125864cf764de |
|
MD5 | 32166e98744087bd582564edef59d78f |
|
BLAKE2b-256 | 61ebbb7a27b37f444ea9f6ebb5b08b525d73de26c653764954a181dfb75a0281 |
Hashes for mlprodict-0.8.1826-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a39cef79a77cddb21713075c84d15e938e98dd879fcf6e91fb14cda0800a7c03 |
|
MD5 | 8b28982148f2ad55e021180bf934afa2 |
|
BLAKE2b-256 | c91c0dd7c75bb2b845284fc4eef5fec1f9f2131bc4a92f73bfcf2710c8d210d2 |