Export from scikit-learn

Save your trained model or Pipeline as ONNX, as it is.

pip install skl2onnx onnxruntime

Export

from skl2onnx import to_onnx

onx = to_onnx(model, X[:1].astype("float32"), options={"zipmap": False})
open("model.onnx", "wb").write(onx.SerializeToString())

model is your trained model or Pipeline, and X your training data. zipmap: False returns probabilities as plain numbers, so PeekML can show them as bars. Leave it out for regression models.

Then

Publish model.onnx. PeekML shows one box per feature. To name them and the classes, see Naming your features.

Text columns

If your data has text columns (like education: masters) encoded inside a Pipeline, give the model one input per column, so the text can go in as text:

from skl2onnx.common.data_types import FloatTensorType, StringTensorType

inputs = [(c, FloatTensorType([None, 1])) for c in ["age", "income"]] \
       + [(c, StringTensorType([None, 1])) for c in ["education"]]
onx = to_onnx(model, initial_types=inputs, options={"zipmap": False})

Each column becomes its own field, named after it; text columns get a dropdown once you list their values (Inputs).

Custom Python steps (FunctionTransformer, pandas code) can't be saved to ONNX. Use built-in scikit-learn transformers, or apply the step before training.