You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had an issue when using "convert_sparkml" to export GBTRegressor model to ONNX model.
What I experienced is, when I predict using the ONNX model, the output type is int64. I wonder if the conversion step changes regression model to a classifier.
Here is the simplified steps to reproduce my issue:
# Creating the gbm regressor objectgbm=GBTRegressor(featuresCol='features', labelCol='label')
# Training the model with train datagbm_model=gbm.fit(train_df)
initial_types= [('features', FloatTensorType([None, 4]))] # Four feature columns with float variable types# Convert the trained model (gbm_model) to ONNXonnx_model=convert_sparkml(gbm_model, 'GBT Regressor Model', initial_types, spark_session=spark)
# Save the ONNX model to a filewithopen("gbt_model.onnx", "wb") asf:
f.write(onnx_model.SerializeToString())
importonnxruntimeasrt# Load the ONNX modelsess=rt.InferenceSession("gbt_model.onnx", providers=["CPUExecutionProvider"])
# Prepare input as a numpy arrayinput_data=np.array([[1.0, 0.0, 5.3, 259.9]], dtype=np.float32)
# Run the modelinput_name=sess.get_inputs()[0].namelabel_name=sess.get_outputs()[0].namepredictions=sess.run([label_name], {input_name: input_data})
print("Predicted value:", predictions)
And the output is:
Predicted value: [array([1], dtype=int64)]
I tested the same steps with RFRegressor instead of GBTRegressor and the output was as I expected.
I would appreciate if you could check convert_sparkml for GBTRegressor.
The text was updated successfully, but these errors were encountered:
I had an issue when using "convert_sparkml" to export GBTRegressor model to ONNX model.
What I experienced is, when I predict using the ONNX model, the output type is int64. I wonder if the conversion step changes regression model to a classifier.
Here is the simplified steps to reproduce my issue:
And the output is:
Predicted value: [array([1], dtype=int64)]
I tested the same steps with RFRegressor instead of GBTRegressor and the output was as I expected.
I would appreciate if you could check convert_sparkml for GBTRegressor.
The text was updated successfully, but these errors were encountered: