Deploying a XGBoost model

As mentioned in the deploying models guide, deploying models via Verta Inference is a two step process: (1) first create an endpoint, and (2) update the endpoint with a model.
This tutorial explains how Verta Inference can be used to deploy an XGBoost model.

1. Create an endpoint

Users can create an endpoint using Client.create_endpoint() as follows:
wine_endpoint = client.create_endpoint(path="/wine")

2. Updating the endpoint with a RMV

As discussed in the Catalog Overview, there are multiple ways to create an RMV for a XGBoost model.
Verta supports directly logging and deploying a model object from XGBoost's Scikit-Learn API. The XGBoost convenience function can be used to create a Verta Standard Model:
Note that in addition to xgboost, this also requires scikit-learn as a dependency for deployment.
from verta.environment import Python
model_version = registered_model.create_standard_model_from_xgboost(
environment=Python(requirements=["xgboost", "scikit-learn"]),
Alternatively, an XGBoost saved model can be used as an artifact in a class that extends VertaModelBase, which is useful for deploying XGBoost's typical Booster models:
from verta.environment import Python
from verta.registry import VertaModelBase, verify_io
from xgboost import Booster, DMatrix
class Model(VertaModelBase):
def __init__(self, artifacts):
self.model = Booster()
def predict(self, input):
input = DMatrix(input)
output = self.model.predict(input)
return output.tolist()
model_version = registered_model.create_standard_model(
artifacts={"xgb_model": "path/to/model.json"},
Regardless of how a Registered Model Version has been created, the endpoint defined above can now be upated and we can make predictions against it.
wine_endpoint = client.get_or_create_endpoint("wine")
wine_endpoint.update(model_version, wait=True)
deployed_model = wine_endpoint.get_deployed_model()
The full code for this tutorial can be found here.