Skip to main content

Python Runtime for ONNX models, other helpers to convert machine learned models in C++.

Project description

Build status Build Status Windows https://circleci.com/gh/sdpython/mlprodict/tree/master.svg?style=svg https://badge.fury.io/py/mlprodict.svg MIT License Requirements Status https://codecov.io/github/sdpython/mlprodict/coverage.svg?branch=master GitHub Issues Notebook Coverage

mlprodict

The packages explores ways to productionize machine learning predictions. One approach uses ONNX and tries to implement a runtime in python / numpy or wraps onnxruntime into a single class. The package provides tools to compare predictions, to benchmark models converted with sklearn-onnx.

The second approach consists in converting a pipeline directly into C and is not much developed.

from sklearn.linear_model import LinearRegression
from sklearn.datasets import load_iris
from mlprodict.onnxrt import OnnxInference, measure_relative_difference
import numpy

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 skl2onnx import to_onnx
model_onnx = to_onnx(lr, X.astype(numpy.float32))

# Predictions with onnxruntime
oinf = OnnxInference(model_onnx, runtime='onnxruntime1')
ypred = oinf.run({'X': X[:5]})
print(ypred)

# Measuring the maximum difference.
print(measure_relative_difference(expected, ypred))

History

current - 2019-07-05 - 0.00Mb

  • 13: add automated benchmark of every scikit-learn operator in the documentation (2019-07-05)

  • 12: implements a way to measure time for each node of the ONNX graph (2019-07-05)

  • 11: implements a better ZipMap node based on dedicated container (2019-07-05)

  • 7: implement python runtime for scaler, pca, knn, kmeans (2019-07-05)

  • 8: implements runtime for decision tree (2019-07-05)

  • 10: implements full runtime with onnxruntime not node by node (2019-06-16)

  • 9: implements a onnxruntime runtime (2019-06-16)

  • 6: first draft of a python runtime for onnx (2019-06-15)

  • 5: change style highlight-ipython3 (2018-01-05)

0.1.11 - 2017-12-04 - 0.03Mb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlprodict-0.2.272.tar.gz (90.8 kB view details)

Uploaded Source

File details

Details for the file mlprodict-0.2.272.tar.gz.

File metadata

  • Download URL: mlprodict-0.2.272.tar.gz
  • Upload date:
  • Size: 90.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for mlprodict-0.2.272.tar.gz
Algorithm Hash digest
SHA256 1a71ca358470d820e6a21e3f2e50801799685bcdbb3dbe32a32cfe83d7f7d155
MD5 e39af9b879627faa28e9620eb6b73cb6
BLAKE2b-256 2da63c9e190ad9a33295ee4ca354e1e887e6dfc901940230e8ba32b905afcde1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page