Skip to content
New issue

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

onnx converted : xgboostRegressor multioutput model predicts 1 dimension instead of original 210 dimensions. #676

Open
devspatron opened this issue Jan 16, 2024 · 4 comments

Comments

@devspatron
Copy link

devspatron commented Jan 16, 2024

Hello machine learning engineers, i have tried to convert an xgboost regressor multi-output model trained on dataset shape=(1000, 210).
on the python runtime the model prediction predicts the correct shape = (1000,210) . However after converting the model into ONNX, the resulting onnx file is used with onnx_model = onnx_RT.InferenceSession(model_file_name), only predicts one dimension shape = (1000,1) instead of shape = (1000,210)

# code as follows:
import xgboost
import numpy as np
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx import update_registered_converter

# Your data and labels
X = np.random.rand(100, 10)
y = np.random.rand(100, 210)

# Train XGBoost regressor
model = xgboost.XGBRegressor(objective='reg:squarederror', n_estimators=100)
model.fit(X, y)

# Define input type (adjust shape according to your input)
initial_type = [('float_input', FloatTensorType([None, X.shape[1]]))]

# Convert XGBoost model to ONNX
onnx_model = convert_sklearn(model, initial_types=initial_type, target_opset=12)

# Save the ONNX model
with open("xgboost_model.onnx", "wb") as f:
    f.write(onnx_model.SerializeToString())

please help ASAP, PLEASE

@devspatron devspatron changed the title xgboost multioutput model predicts 1 dimension instead of original 210 dimensions. onnx converted : xgboostRegressor multioutput model predicts 1 dimension instead of original 210 dimensions. Jan 16, 2024
@xadupre
Copy link
Collaborator

xadupre commented Feb 8, 2024

Did you try since the PR was merged?

@devspatron
Copy link
Author

devspatron commented Feb 14, 2024 via email

@devspatron
Copy link
Author

devspatron commented Mar 10, 2024 via email

@giorgostheo
Copy link

Hi,

I am experiencing the same problem with @devspatron. Onnx'ed model predicts just 1d instead of 2d in my case. Any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants