<jupyter_start><jupyter_text>H2O Model * Wrap a H2O model for use as a prediction microservice in seldon-core   * Run locally on Docker to test   * Deploy on seldon-core running on minikube  Dependencies * [Helm](https://github.com/kubernetes/helm) * [Minikube](https://github.com/kubernetes/minikube) * [S2I](https://github.com/openshift/source-to-image) * [H2O](https://www.h2o.ai/download/)```bashpip install seldon-corepip install sklearn``` Train locally<jupyter_code>!mkdir -p experiment
import h2o
h2o.init()
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
path = "http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv.zip"
h2o_df = h2o.import_file(path)
h2o_df['CAPSULE'] = h2o_df['CAPSULE'].asfactor()
model = H2OGeneralizedLinearEstimator(family = "binomial")
model.train(y = "CAPSULE",
            x = ["AGE", "RACE", "PSA", "GLEASON"],
            training_frame = h2o_df)
modelfile = model.download_mojo(path="./experiment/", get_genmodel_jar=False)
print("Model saved to " + modelfile)

!mv experiment/*.zip src/main/resources/model.zip<jupyter_output><empty_output><jupyter_text>Wrap model using s2i<jupyter_code>!s2i build . seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
!docker run --name "h2o_predictor" -d --rm -p 5000:5000 h2o-test:0.1<jupyter_output>43545db7b7f0ee3a6188811d05525d019c5feaaef37779d8e3795205a5664c22<jupyter_text>Send some random features that conform to the contract<jupyter_code>!seldon-core-tester contract.json 0.0.0.0 5000 -p
!docker rm h2o_predictor --force<jupyter_output>h2o_predictor<jupyter_text>Test using Minikube**Due to a [minikube/s2i issue](https://github.com/SeldonIO/seldon-core/issues/253) you will need [s2i >= 1.1.13](https://github.com/openshift/source-to-image/releases/tag/v1.1.13)**<jupyter_code>!minikube start --memory 4096 
!kubectl create clusterrolebinding kube-system-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
!helm init
!kubectl rollout status deploy/tiller-deploy -n kube-system
!helm install ../../../helm-charts/seldon-core-operator --name seldon-core --set usageMetrics.enabled=true   --namespace seldon-system
!kubectl rollout status deploy/seldon-controller-manager -n seldon-system<jupyter_output>partitioned roll out complete: 1 new pods have been updated...<jupyter_text>Setup IngressPlease note: There are reported gRPC issues with ambassador (see https://github.com/SeldonIO/seldon-core/issues/473).<jupyter_code>!helm install stable/ambassador --name ambassador --set crds.keep=false
!kubectl rollout status deployment.apps/ambassador<jupyter_output>Waiting for deployment "ambassador" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "ambassador" rollout to finish: 1 of 3 updated replicas are available...
Waiting for deployment "ambassador" rollout to finish: 2 of 3 updated replicas are available...
deployment "ambassador" successfully rolled out<jupyter_text>Build model image and run predictions<jupyter_code>!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
!kubectl create -f h2o_deployment.json<jupyter_output>seldondeployment.machinelearning.seldon.io/seldon-deployment-example created<jupyter_text>Wait until ready (replicas == replicasAvailable)<jupyter_code>!kubectl rollout status deployment/h2o-deployment-h2o-predictor-1cc70ed
!seldon-core-api-tester contract.json `minikube ip` `kubectl get svc ambassador -o jsonpath='{.spec.ports[0].nodePort}'` \
    seldon-deployment-example --namespace seldon -p
!minikube delete<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12358946802794196, 'fraction_numerical': 0.03707684040838259, 'mean_word_length': 5.660107334525939, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 7, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '162632', 'license': 'Apache-2.0', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1323, 'n_words': 267, 'path': 'examples/models/h2o_mojo/h2o_model.ipynb', 'repo_name': 'peter-vandenabeele-axa/seldon-core', 'size': '3722'}