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.1858-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d6fdf55b0081a59740398ef0add28a64379a1a4c936c7deee1ba67793cb317c |
|
MD5 | ebfc7deba9fe99d070e63f6cea6009b4 |
|
BLAKE2b-256 | 74268b5dda74cf9bc959a286bc1694d0f2b53a7e0040987baba25fdb48a08f32 |
Hashes for mlprodict-0.8.1858-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 990dc065140196fdb7b99074653d858a0746a3dfdfea7fc93b8d347fc7dddc92 |
|
MD5 | 86ebf2ffb1add81aa3d6254c3f52fe6b |
|
BLAKE2b-256 | ecc884d6945ad0f9ddc09ad215b596dfd88119e0bd9025d4a20dafe3e7800a38 |
Hashes for mlprodict-0.8.1858-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecec56afdaad835856bed49d9c059878d1a4ce4ef468d1c93262c55799b012d2 |
|
MD5 | d14ecb8077d789b239fc984161b12d21 |
|
BLAKE2b-256 | dee8ebd3b967c253dd6de13bf389698c6d25ec1f771ab3e2c601d23bc5b18878 |
Hashes for mlprodict-0.8.1858-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 414b29ef25ff0753d142dc09841cd25c3403bf8800d34e7c276deb38cbea2473 |
|
MD5 | 56359e759ecd02b6c22961f2f72b6ec8 |
|
BLAKE2b-256 | d59ed47d1d4ea521b2d70b024026b09b54f1782d6a66c1262eb06c8d7ec11d79 |
Hashes for mlprodict-0.8.1858-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7be070cabac6b835c8330ea491509c7a8b212ca3d1e1fea71cd917764d5df13 |
|
MD5 | bee223fc7bec0d85d2f095e143682b56 |
|
BLAKE2b-256 | 54e3eb3cde1df7fb44a7bd656023da2aab2899919d277dd46a59ef1c82423d35 |
Hashes for mlprodict-0.8.1858-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f801ccb70803e9dbdff4d2ac3ba78357e83f82d9557b9a580d19b65ce16f9a69 |
|
MD5 | 6992cb5e1d148a4e1fb73c9b2754f9c1 |
|
BLAKE2b-256 | 8ebd3f3a33a012e0231680eedc48a9848597be9b98a5bc218c148ee28cb86799 |
Hashes for mlprodict-0.8.1858-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699b4c23976e306152da75c3469617101ad63958e135c32c5f52f23f1adb9d13 |
|
MD5 | df7e8c8390f6f66a780fc5def9d93d49 |
|
BLAKE2b-256 | 2a7cacc94c689780029df261565d8a3b2c7b84ec10200a73958e0f4bb7491983 |
Hashes for mlprodict-0.8.1858-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c1a0bf81dc59c0b021719678ff9b5bfdf7dd07f29266d07d0d0a45100037a5 |
|
MD5 | 3bce6ddfe1704ac33e380b24e93994a9 |
|
BLAKE2b-256 | cfbbb248fc1794747848964a0a42b73b684d8da47a015c2a291ae1a2e2ba115b |