This example will take you through creating a simple prediction service to serve predictions for the Iris dataset. The predictive service will be deployed as a microservice inside Kubernetes allowing roll-back/up for scalable maintenance. It will be accessed via the Seldon server allowing you to run multiple algorithms and manage predictive services for many clients.
- You have installed Seldon on a Kubernetes cluster
- You haved added
seldon-server/kubernetes/binto you shell PATH environment variable.
The first step is to create a predictive model based on some training data. In this case we have prepacked into 4 Docker images the process of creating a model for the Iris dataset using popular machine learning toolkits XGBoost, Vowpal Wabbit, Keras and Scikit-learn. Wrappers to call these libraries have been added to our python library to make integrating them as a microservice easy. However, you can build your model using any machine learning library.
The four example images are:
- seldonio/iris_xgboost : an XGBoost model for the iris dataset
- seldonio/iris_vw : a VW model for the iris dataset
- seldonio/iris_keras : a keras model for the iris dataset
- seldonio/iris_scikit : a scikit-learn model for the iris dataset
For details on building models using our python library see here.
At runtime Seldon requires you expose your model scoring engine as a microservice API. In this example case the same image to create the models also exposes it for runtime scoring when run. We can start our chosen microservice using the command line script start-microservice
The script creates a Kubernetes deployment for the microservice in
kubernetes/conf/microservices. If the microserice is already running Kubernetes will roll-down the previous version and roll-up the new version.
For example to start the XGBoost Iris microservice on the client “test” (created by seldon-up on startup):
kubectl get pods -l name=iris-xgboost that the pod running the mircroservice is running.
You can now call the seldon server using the seldon CLI to test:
The respone should be like:
The models for the Iris dataset are created using our pyseldon library to wrap calls to XGBoost and use Pandas along with a feature transform to normalise the features. The XGBoost version is shown below:
To run the runtime scorer for this model we load the model and using the pyseldon wrapper to start a simple Http server.
The full source code to create a docker image for model and runtime scorer for the three variants can be found in:
- docker/examples/iris/xgboost : an XGBoost model for the iris dataset
- docker/examples/iris/vw : a VW model for the iris dataset
- docker/examples/iris/keras : a keras model for the iris dataset
- docker/examples/iris/scikit : a scikit-learn model for the iris dataset