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.1863-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 580fa4d0b572ccfc0bc0b594a887178bbe940a93a931437b2eacd9fa366b7d19 |
|
MD5 | 2b4a828fab9bc754e6652b3d3d3face1 |
|
BLAKE2b-256 | ab0b521249c507befad727dadbd37910a86ecbe30f6f35f9a58a14cdc90ba863 |
Hashes for mlprodict-0.8.1863-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9373afba36feb01ea229a2e60bcd5973c0d49ae91d54ca7275caf5df4bfca218 |
|
MD5 | 82976e323a50d69a2396489a38c7253c |
|
BLAKE2b-256 | 23774cbff33175213e307578a360144b81f8899c8d9bfba6700128416f2373b3 |
Hashes for mlprodict-0.8.1863-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a495d14fcb041f4ae71cb2e0eb947340f2d47bb84e2df954f41c2392e4e88acd |
|
MD5 | 64059bea220d8e76cb629732c0965b2b |
|
BLAKE2b-256 | fd2363511271eb72acc58e69960ba2d6d82df24abb9c696551d40a273ff13142 |
Hashes for mlprodict-0.8.1863-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a113573b9e4be357d02ec58ada3dc641fdbcc0663cc94dee4915bba12fb43064 |
|
MD5 | fbb8ce965c09e591068460e2107ab83c |
|
BLAKE2b-256 | 8de00f5c7b1b265380719e08ade87e377c0aedfd2260ebc1c26955a418b662b7 |
Hashes for mlprodict-0.8.1863-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3ba491f6c370006945ae45817f24553fefc5a82ad4d43a401e73ffed9addae5 |
|
MD5 | dc9ac9bd0fbcc5050031509dbbbbb043 |
|
BLAKE2b-256 | f3d3ff36ef48689f97ae444eb8a3339de4b3ca67ea72a9e6619890ab40961d12 |
Hashes for mlprodict-0.8.1863-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a94f54f10f6cb1acee7b56a050a399953bfec0ea8b47aac4173dd078fff358a |
|
MD5 | 336f293cab5f9887f78f9a957c18ff89 |
|
BLAKE2b-256 | c330026cebc5e77d257985693247eca3c5a6052fb8f1b944b5d24d85bec17593 |
Hashes for mlprodict-0.8.1863-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ed0ccaa6755a09ce54d08b19c7f660d203e8d932fd19905de127823f9bf1ebf |
|
MD5 | 233e4962574b0317fd4e58cd1c0cc8fc |
|
BLAKE2b-256 | 0dcefdc98eea27733f0bb0966ce642943c08ed073cec4e2714690f6d15a88e62 |
Hashes for mlprodict-0.8.1863-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 075b7348703f45ff99a7ff523557ab7d4be58ad5b2d1d0fa4e58743ac8d909c2 |
|
MD5 | d8e6e310117957eaaed022c554aebfab |
|
BLAKE2b-256 | 3dc9217a86005bf9316a305bf60b1313c3f4ad64f65233c75103a4ecaac8cf71 |
Hashes for mlprodict-0.8.1863-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40d106aa9514ad16fdb65d3748b877edba2b191fa698d006a618b111054e2909 |
|
MD5 | 564879e3484d4633d7241dc825173445 |
|
BLAKE2b-256 | ab6a8f4c909a159c510958bb80469271f8295a51471c732914e8c72188e9775e |
Hashes for mlprodict-0.8.1863-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f7a9785a2aacbe69da9ad63c64a3228ef208003b8a2f038c25e636d2ad2536 |
|
MD5 | afff3d3be0f8ef8eb9477ec0379f1f02 |
|
BLAKE2b-256 | afe4e3a917acfa9f5645311ef74b9ad1004255babaa4cbbb4b53b24b2c40ccec |
Hashes for mlprodict-0.8.1863-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dfd41b22b4aabdcc3d6d37ef65f6047366e7b53d5c727cce175ecbe9f981c82 |
|
MD5 | c5b2afabe7145280512c68041dc062bf |
|
BLAKE2b-256 | c80eb98e582b86a65a78cdf8db864c3db9fef9db4dd9bf16d38467aa4ef75596 |