Quick start

Train a small model, save it as ONNX and put it on PeekML in about five minutes.

1Install

pip install scikit-learn skl2onnx

2Train and save

from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from skl2onnx import to_onnx

X, y = load_iris(return_X_y=True)
model = LogisticRegression(max_iter=500).fit(X, y)

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

This creates iris.onnx: a model that tells three kinds of iris flowers apart from four measurements.

3Publish

Log in with GitHub, open Publish, drop in iris.onnx and press Publish model. Your page shows four number boxes and the prediction.

4Name things (optional)

Save this as peekml.yaml and publish it together with iris.onnx to name the boxes and the classes, and add “Try an example” buttons:

info:
  title: Iris species

inputs:
  properties:
    X:
      type: array
      x-columns: [sepal_length, sepal_width, petal_length, petal_width]

outputs:
  properties:
    probabilities:
      type: array
      x-classes: [setosa, versicolor, virginica]

examples:
  - [5.1, 3.5, 1.4, 0.2]
  - [5.9, 3.0, 5.1, 1.8]

5Share

Anyone can try it at /your-username/iris-species, no login needed.

Next