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:
tag = bentoml.sklearn.save_model('kneighbors', model)

# retrieve metadata with `bentoml.models.get`:
metadata = bentoml.models.get(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(tag).to_runner()


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