After we have created a model we will typically want to save it as a binary file so it can be deployed for prediction.
Seldon core is a model deployment engine. Here is an excerpt from the seldon documentation for Scikit-learn deployments
Seldon expects that your model has been saved using joblib, and it named as model.joblib. Note that this is the recommended approach to serialise models by the SKLearn project.
Source: https://docs.seldon.io/projects/seldon-core/en/latest/servers/sklearn.html
# set the random state to make the examples repeatable
import numpy as np
np.random.seed(1)
from sklearn.datasets import load_iris
from sklearn.svm import LinearSVC
iris = load_iris()
X, y = iris.data, iris.target
classifier = LinearSVC()
model = classifier.fit(X, y)
from joblib import dump, load
dump(model, 'iris_model.joblib')
/opt/conda/lib/python3.9/site-packages/sklearn/svm/_base.py:1206: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn(
['iris_model.joblib']
We can execute a shell command with !
. Let's inspect the saved file:
! ls -l iris_model.joblib
-rw-r--r-- 1 jovyan users 858 Feb 11 15:23 iris_model.joblib