onnx / sklearn-onnx

Convert scikit-learn models and pipelines to ONNX
Apache License 2.0
557 stars 104 forks source link

Error in converting SageMaker model to onnx #326

Closed csharpbd closed 3 years ago

csharpbd commented 5 years ago

I'm trying to convert a SageMaker XGBoost model to ONNX. 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. I've load the model successfully by using pickle and joblib. But it's shown error, when I'm going to convert the model to onnx using sklearn-onnx. Please take a look at the attached images for more details about the error.

sklearn-onnx #1 sklearn-onnx #2

Could you please take a look at the issues and let me know a way to solve the issues? Thanks in advance!

xadupre commented 5 years ago

There is no solution yet. There is no converter in onnxmltools for a xgboost booster yet (see https://github.com/onnx/onnxmltools/issues/349).

csharpbd commented 5 years ago

@xadupre thanks for your reply. I've tried the winmltools and onnxmltools but unfortunetly the tools are not working. Already I've posted a question on StackOverflow about it. You can find the question Error in converting SageMaker XGBoost model to ONNX model I've tried to explain each steps that I followed to convert the mode to ONNX model. Could you please take a look at the question? I hope you may help me.

xadupre commented 5 years ago

winmltools is using onnxmltools. That's why it does not work. I can try to have a fix by the end of the week. Would that work for you?

csharpbd commented 5 years ago

Sure, that will help me a lot. Thank you for your kindness.

xadupre commented 5 years ago

I made a PR: https://github.com/onnx/onnxmltools/pull/355. You need to use onnxmltools from this branch: https://github.com/xadupre/onnxmltools/tree/xgbb. Let me know if it fixes your issue. I still have some doubts because it does not seem possible to retrieve the objective function from a booster. I only guess which kind of problem it is (classifier, regressor) but I might require an extra parameter if it does not work.

csharpbd commented 5 years ago

@xadupre I'm sorry for late response. I've tried to convert the model to onnx after installing the xgbb branch. But I got an error. Actually I'm new in this field, I don't have enough and I'm struggling to get the desired result. Please take a look at the attached image and please guide me, what should I do now.

image

xadupre commented 5 years ago

The PR has been merged. So it should be easier to install. I don't see any error, just a warning we should probably remove. You need to test your model with a runtime now (onnxruntime for example). You should also use None instead of 'None' when you specify the shape.

csharpbd commented 5 years ago

Thanks @xadupre the model is converted to onnx and I can save the model as .onnx format. I'm working to check the model using ML.NET. I will back to you after testing the model.

xadupre commented 3 years ago

I'll close the issue. Feel free to reopen it.