Below is a simple example of using scikit-learn with BentoML:

import bentoml

from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier

model = KNeighborsClassifier()
iris = load_iris()
X =[:, :4]
Y =, Y)

# `save` a given classifier and retrieve coresponding tag:
bento_model = bentoml.sklearn.save_model('kneighbors', model)

# retrieve metadata with `bentoml.models.get`:
metadata = bentoml.models.get(bento_model.tag)

# load the model back:
loaded = bentoml.sklearn.load_model("kneighbors:latest")

# Run a given model under `Runner` abstraction with `to_runner`
runner = bentoml.sklearn.get(bento_model.tag).to_runner()


You can find more examples for scikit-learn in our bentoml/examples directory.