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.
Release files for mlprodict 0.9.1883
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mlprodict-0.9.1883.tar.gz | 814.9 kB | Details |
Built distributions (wheels)
Total release size: 171.1 MB
Release files / mlprodict-0.9.1883.tar.gz
| Download URL | mlprodict-0.9.1883.tar.gz |
|---|---|
| Size | 814.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4be87c687d3d09b6a7f55eeb90d0795fc84a969c271ad4053ef53015d06dd398
|
|
BLAKE2b-256 checksum How to use checksums |
5bd27f643bb8432e9c7961becb4f44e0e0f8455dffa92344c6e4ca7b4d18d232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp310-cp310-win_amd64.whl
| Download URL | mlprodict-0.9.1883-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a39323222595cb9f7ce16d167febd670e41be5c26ac334e475978266c3b494e6
|
|
BLAKE2b-256 checksum How to use checksums |
8c05ca4996e5cd1aa11af640f2d29b3ae40d1a0deaa5a42bde4329daeaa97940
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp310-cp310-manylinux_2_24_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp310-cp310-manylinux_2_24_x86_64.whl |
|---|---|
| Size | 27.4 MB |
| Tags | CPython 3.10 Linux glibc 2.24+ x86-64 |
|
SHA-256 checksum How to use checksums |
9460033d0331aaefe79d19e45aa5ef04663ad2d89a3edcf674b64c8087c07101
|
|
BLAKE2b-256 checksum How to use checksums |
6fcf97957338b23f937d337e1b8ec9047aa19987257a1c9889ebe640e2fad5a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp310-cp310-macosx_10_13_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp310-cp310-macosx_10_13_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.10 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ca38c90d5f0ddf7715ec171074a5ed13265d1a70df69f718996b4824243b6af
|
|
BLAKE2b-256 checksum How to use checksums |
54f91b152e47b910991107edbfdf7d14270d518883f18f9748d7cd1251fa2e10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp39-cp39-win_amd64.whl
| Download URL | mlprodict-0.9.1883-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
15465beed3fb1504a03d15986cff2c962d30fede0c6a04b248d24d4c32ac728a
|
|
BLAKE2b-256 checksum How to use checksums |
90076ce9f5f6579c56cfa827ff155d8600d62a9d7d93367555592c799d234a45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 40.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a97172bddfb16467992d17bc673f0ed8e11b626e5ed711fdfb4a99c5e07196c
|
|
BLAKE2b-256 checksum How to use checksums |
76c4231e76b59c9d0252e990afc710e8c919f7ec3bce38677b3bb72c14b31853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp39-cp39-macosx_10_13_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp39-cp39-macosx_10_13_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.9 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a2843aabf25433967fa80bae244dc6eff3a42a7e947d03c47fdb93ac215fef8
|
|
BLAKE2b-256 checksum How to use checksums |
05ac6d9ffe86930951d3418604fd97b05dc4afa02a07e1a0ee387dca8b3258ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp38-cp38-win_amd64.whl
| Download URL | mlprodict-0.9.1883-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fda5699f053b6014470b4bc645949a4fa6bb8246bbfdb090a50390efbcc421f0
|
|
BLAKE2b-256 checksum How to use checksums |
ccbcb2ca328e32f8098cddb69c8c99033ceff538b695ca5fed4914182c3138d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 40.1 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2d4ab90f145174ac71a556466ae374c0e51145957f71ede2fa78119696934774
|
|
BLAKE2b-256 checksum How to use checksums |
1e3c53a12d2942e6821231503d571cf3b67d72d239d858b0b987af17a0d716ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp38-cp38-macosx_10_13_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp38-cp38-macosx_10_13_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.8 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
3d0f71d940a622960e528e4be6d6bd4eea901d0bfc0e5a81c90de5310e2e64a3
|
|
BLAKE2b-256 checksum How to use checksums |
7898f012e83f9f028f2f06bcb10724bc6415049e9660cf6c62da9fa345ef5b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp37-cp37m-win_amd64.whl
| Download URL | mlprodict-0.9.1883-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a6e4945379e5378532c35d9054538655407f081838b2c11158f73bcc5f10d65d
|
|
BLAKE2b-256 checksum How to use checksums |
97a6e83adbcd805fe583dfcdf4557f5b6a3ca3b3459fe22293aad21b3e6ebc2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / mlprodict-0.9.1883-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mlprodict-0.9.1883-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 41.3 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
215c9a413fa9b24e66b6274daa4395f5d2713a7f7b718641e13abe908b42101c
|
|
BLAKE2b-256 checksum How to use checksums |
9b5db36f8b0543089319fd82a0b4ff91e3206862b25c9b7dfcb57130f34030b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|