5

I'm trying to convert a SageMaker XGBoost model to ONNX, in order to use the ONNX model in .Net application using ML.NET. I've tried to convert the model using winmltools and onnxmltools but both tools are returned similar error.

There is a good resource to use machine learning in business area. I've tried Using Machine Learning to Improve Sales in SageMaker to create the model and then convert the model to ONNX model. The example is working well in SageMaker.

enter image description here

After running the example, I got a model and the type of the model is sagemaker.estimator.Estimator. I've tried to convert the model by using winmltools and onnxmltools. But both are returned same error.

ValueError: No proper operator name found for '<class 'sagemaker.estimator.Estimator'>'

enter image description here

I've tried to follow Convert ML models to ONNX with WinMLTools and ONNXMLTools enables conversion of models to ONNX to convert the SageMaker model to ONNX model.

After that, I used xgb.create_model() command to create SageMaker model. Then used the tools to convert the model to ONNX. but no luck. I got same error this time. Just the model is different.

ValueError: No proper operator name found for '<class 'sagemaker.model.Model'>'

enter image description here

Then I load the model using pickle and tried to convert the model. I got same error, just the model is different.

ValueError: No proper operator name found for '<class 'xgboost.core.Booster'>'

enter image description here

At this moment, I have no idea about the issues. How should I solve the issues. I've attached the Improve Sales Classification to ONNX notebook file for reference. Could you please take a look at the issues and let me know a way to solve the issues? Thanks in advance!

csharpbd
  • 3,786
  • 4
  • 23
  • 32
  • Did you try loading the model from the file using the XGBRegressor class (https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.XGBRegressor.load_model)? – Guy Nov 28 '19 at 10:17
  • @Guy yes, I tried that. Please check the attached image for details. https://drive.google.com/open?id=1Trl2hPKFY1PqCOp6xaNnpJZors8GP8SV – csharpbd Nov 28 '19 at 12:59
  • Please note that, the model is loaded successfully but conversion is not worked. – csharpbd Nov 28 '19 at 13:09
  • The error in the image is talking about payment_date not int. What is payment_date in your features and how did you encode it for the xgboost modelling? – Guy Nov 30 '19 at 11:03

0 Answers0