Wallaroo Upload and Deploy Tutorials: XGBoost

How to upload different XGBoost models to Wallaroo.

The following tutorials cover how to upload sample XGBoost models.

ParameterDescription
Web Sitehttps://xgboost.ai/
Supported Libraries
  • scikit-learn==1.3.0
  • xgboost==1.7.4
FrameworkFramework.XGBOOST aka xgboost
Supported File Typespickle (XGB files are not supported.)

During the model upload process, Wallaroo optimizes models by converting them to the Wallaroo Native Runtime, if possible, or running the model directly in the Wallaroo Containerized Runtime. See the Model Deploy for details on how to configure pipeline resources based on the model’s runtime.

Since the Wallaroo 2024.1 release, XGBoost support is enhanced to performantly support a wider set of XGBoost models. XGBoost models are not required to be trained with ONNX nomenclature in order to successfully convert to a performant runtime.

XGBoost Types Support

The following XGBoost model types are supported by Wallaroo. XGBoost models not supported by Wallaroo are supported via the Arbitrary Python models, also known as Bring Your Own Predict (BYOP).

XGBoost Model TypeWallaroo Packaging Supported
XGBClassifier
XGBRegressor
Booster Classifier
Booster Classifier
Booster Regressor
Booster Random Forest Regressor
Booster Random Forest Classifier
XGBRFClassifier
XGBRFRegressor
XGBRanker*X
  • XGBRanker XGBoost models are currently supported via converting them to BYOP models.

XGBoost Schema Inputs

XGBoost schema follows a different format than other models. To prevent inputs from being out of order, the inputs should be submitted in a single row in the order the model is trained to accept, with all of the data types being the same. If a model is originally trained to accept inputs of different data types, it will need to be retrained to only accept one data type for each column - typically pa.float64() is a good choice.

For example, the following DataFrame has 4 columns, each column a float.

 sepal length (cm)sepal width (cm)petal length (cm)petal width (cm)
05.13.51.40.2
14.93.01.40.2

For submission to an XGBoost model, the data input schema will be a single array with 4 float values.

input_schema = pa.schema([
    pa.field('inputs', pa.list_(pa.float64(), list_size=4))
])

When submitting as an inference, the DataFrame is converted to rows with the column data expressed as a single array. The data must be in the same order as the model expects, which is why the data is submitted as a single array rather than JSON labeled columns: this insures that the data is submitted in the exact order as the model is trained to accept.

Original DataFrame:

 sepal length (cm)sepal width (cm)petal length (cm)petal width (cm)
05.13.51.40.2
14.93.01.40.2

Converted DataFrame:

 inputs
0[5.1, 3.5, 1.4, 0.2]
1[4.9, 3.0, 1.4, 0.2]

XGBoost Schema Outputs

Outputs for XGBoost are labeled based on the trained model outputs.

Outputs for XBoost that are meant to be predictions or probabilities must be labeled as part of the output schema. For example, a model that outputs either 1 or 0 as its output would have the output schema as follows:

output_schema = pa.schema([
    pa.field('predictions', pa.int32())
])

When used in Wallaroo, the inference result is contained in the out metadata as out.predictions.

pipeline.infer(dataframe)
 timein.inputsout.predictionsanomaly.count
02023-07-05 15:11:29.776[5.1, 3.5, 1.4, 0.2]00
12023-07-05 15:11:29.776[4.9, 3.0, 1.4, 0.2]00

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster Binary Classification Example

How to upload a XGBoost Booster Binary Classification Model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster Multiclass Classification Softmax Tutorial

How to upload a XGBoost Booster Multiclass Classification Softmax model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster Multiclass Classification Softprob

How to upload a XGBoost Booster Multiclass Classification Softprob model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster Regression

How to upload a XGBoost Booster Regression model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster RF Classification

How to upload a XGBoost Booster RF Classification model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Booster RF Regression

How to upload a XGBoost Booster RF Regression model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Classification

How to upload a XGBoost Classification model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost Regressor

How to upload a XGBoost Regressor model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost RF Classification

How to upload a XGBoost RF Classification Model to Wallaroo

Wallaroo SDK Upload and Deploy Tutorial: XGBoost RF Regressor

How to upload a XGBoost RF Regressor Model to Wallaroo