scikit-learn to ONNX Tutorial¶
The tutorial goes from a simple example which converts a pipeline to a more complex example involving operator not actually implemented in ONNX operators or ONNX ML Operators.
- The easy case
- Train and deploy a scikit-learn pipeline
- Benchmark ONNX conversion
- What is the opset number?
- One model, many possible conversions with options
- Black list operators when converting
- Choose appropriate output of a classifier
- Issues when switching to float
- Funny discrepancies
- Intermediate results and investigation
- Dataframe as an input
- Transfer Learning with ONNX
- Store arrays in one onnx graph
- Modify the ONNX graph
- Using converter from other libraries
- A custom converter for a custom model
- Extend ONNX, extend runtime
- Complex Scenarios
The tutorial was tested with following version:
<<<
import sys
import numpy
import scipy
import onnx
import onnxruntime
import lightgbm
import xgboost
import sklearn
import onnxconverter_common
import onnxmltools
import skl2onnx
import pyquickhelper
import mlprodict
import onnxcustom
print("python {}".format(sys.version_info))
mods = [numpy, scipy, sklearn, lightgbm, xgboost,
onnx, onnxmltools, onnxruntime, onnxcustom,
onnxconverter_common,
skl2onnx, mlprodict, pyquickhelper]
mods = [(m.__name__, m.__version__) for m in mods]
mx = max(len(_[0]) for _ in mods) + 1
for name, vers in sorted(mods):
print("{}{}{}".format(name, " " * (mx - len(name)), vers))
>>>
python sys.version_info(major=3, minor=9, micro=1, releaselevel='final', serial=0)
lightgbm 3.3.2
mlprodict 0.8.1747
numpy 1.22.3
onnx 1.11.0
onnxconverter_common 1.10.0
onnxcustom 0.4.293
onnxmltools 1.10.0
onnxruntime 1.11.993+cpu
pyquickhelper 1.11.3711
scipy 1.8.0
skl2onnx 1.11
sklearn 1.0.2
xgboost 1.5.2