microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.71k stars 2.93k forks source link

ONNX XGBoost classifier gives very different results from the original model #11892

Open xiaohk opened 2 years ago

xiaohk commented 2 years ago

Describe the bug

I am converting a simple XGBoost model to ONNX format. However, the results of the ONNX model mismatch the original model, yielding way worse performance.

Urgency

Quite urgent. This bug can cause harm if people deploy their XGBoost model in ONNX format without noticing this error.

System information

To Reproduce

  1. Train an XGBoost classifier on the Adult dataset
  2. Covert the XGBoost model to ONNX using convert_xgboost
  3. Inference ONNX model using InferenceSession

This bug is reproduced in this Colab notebook

Expected behavior

I expect the results of the ONNX model to match the original XGBoost model.

Screenshots

See this Colab notebook

xadupre commented 2 years ago

Thanks for sharing the code was. I was able to replicate the issue. The bug happens when base_score is specified. It needs a fix into onnxmltools.

xiaohk commented 2 years ago

Thanks @xadupre! Should I open a new issue in onnxmltools?

xadupre commented 2 years ago

I created a PR on onnxmltools to fix the issue.