Search code examples
pythonscikit-learnonnx

Is it possible to get tree decision_path from calls to sklearn models saved with skl2onnx?


For example following: https://github.com/onnx/sklearn-onnx/blob/master/docs/tutorial.rst

But with

model = sklearn.ensemble.RandomForestRegressor()

We can get a hold of

models.estimators_[0].decision_path(X)

Can we do this with a model converted to ONNX?

Or is there a way to simply load the ONNX file back into sklearn?


Solution

  • This is unfortunately not possible -- the skl2onnx converter does not expose the decision path in a converted ONNX model. In the case of SciKitLearn's Regressors, we only expose the predicted score in the ONNX model. In Classifiers, we expose the predicted class and the probability / decision function scores.

    There is also no way to take a converted ONNX model and load it back into SciKitLearn.