We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When converting a XGBRegressor with objective="reg:logistic", the onnx model and the XGBoost model give different results.
objective="reg:logistic"
The difference seems to be a sigmoid transformation that is not included in the model.
Here is a script to reproduce:
import numpy as np from onnxmltools import convert_xgboost from skl2onnx.common.data_types import FloatTensorType X_train = np.random.rand(20, 10).astype(np.float32) Y_train = np.random.randint(2, size=20) X_test = np.random.rand(1, 10).astype(np.float32) xg_reg = XGBRegressor(objective="reg:logistic").fit(X_train, Y_train) xg_pred = xg_reg.predict(X_test) xgb_onnx = convert_xgboost(xg_reg, initial_types=[("float_input", FloatTensorType([None, 10]))]) import onnxruntime onx_reg = onnxruntime.InferenceSession(xgb_onnx.SerializeToString()) onnx_pred = onx_reg.run(None, {"float_input": X_test}) print(f"xgboost prediction: {xg_pred}") print(f"onnx prediction: {onnx_pred}") onnx_pred_fixed = 1 / (np.exp(-onnx_pred[0] + 0.5) + 1) print(f"onnx prediction fixed: {onnx_pred_fixed}")
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When converting a XGBRegressor with
objective="reg:logistic"
, the onnx model and the XGBoost model give different results.The difference seems to be a sigmoid transformation that is not included in the model.
Here is a script to reproduce:
The text was updated successfully, but these errors were encountered: