Skip to content

Get raw Booster prediction instead of model.predict_proba values from an XGBoost model #439

@xlr18

Description

@xlr18

I have an XGBoost model that I want to run in Triton server. Currently I'm using the model to get raw prediction probability like this:

model = xgb.XGBClassifier()
model.load_model(str(model_path))
dmat_input = np.reshape(fv, (-1, len(fv)))
dmatrix = xgb.DMatrix(dmat_input, missing=0.0)
probs = model.get_booster().predict(dmatrix, validate_features=False)
return float(probs[0])

When I run the model in Triton I get results that look like the values that I would get it I was doing model.predict_proba(), which is not what I want for my use-case. I want to get the raw booster probability. Is it possible to do so? Below is my config.pbtxt:

name: "mymodel"
backend: "fil"
max_batch_size: 128
input [
  {
    name: "input__0"
    data_type: TYPE_FP32
    dims: [ 2545 ]
  }
]
output [
  {
    name: "output__0"
    data_type: TYPE_FP32
    dims: [ 1 ]
  }
]
instance_group [
  {
    kind: KIND_CPU
  }
]
default_model_filename: "mymodel.json"
parameters [
  {
    key: "model_type"
    value: { string_value: "xgboost_json" }
  },
  {
    key: "predict_proba"
    value: { string_value: "false" }
  },
  {
    key: "threshold"
    value: { string_value: "0.5" }
  },
  {
    key: "output_class"
    value: { string_value: "false" }
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions