ValueError: Unable to create node 'TreeEnsembleClassifier' with name='WrappedLightGbmBoosterClassifier'.
See original GitHub issueHi, I am trying to convert LightGBM Binary Classification model into ONNX.
I have defined calculate_lightgbm_output_shapes, lightgbm_parser, WrappedLightGbmBoosterClassifier functions and used update_registered_converter( WrappedLightGbmBoosterClassifier, 'WrappedLightGbmBoosterClassifier', calculate_lightgbm_output_shapes, convert_lightgbm, parser=lightgbm_parser, options={'zipmap': [False, True], 'nocl': [False, True]})
to update registered converter.
To convert the model, I used
onnx_model = to_onnx(lgm_model, initial_types=[('feature_input', FloatTensorType([None, 2021]))], options={WrappedLightGbmBoosterClassifier: {'zipmap': False}}, target_opset={'': 15, 'ai.onnx.ml': 2})
But I am getting the following error
ValueError: Unable to create node 'TreeEnsembleClassifier' with name='WrappedLightGbmBoosterClassifier'.
This is the error trace : `File ~/jupyter_dir/jupyter_env/lib/python3.8/site-packages/onnxmltools/convert/lightgbm/operator_converters/LightGbm.py:519, in convert_lightgbm(scope, operator, container) 515 probability_tensor_name = scope.get_unique_variable_name( 516 ‘probability_tensor’) 517 label_tensor_name = scope.get_unique_variable_name(‘label_tensor’) –> 519 container.add_node( 520 ‘TreeEnsembleClassifier’, operator.input_full_names, 521 [label_tensor_name, probability_tensor_name], 522 op_domain=‘ai.onnx.ml’, **attrs) 524 prob_tensor = probability_tensor_name 526 if gbm_model.boosting_type == ‘rf’:
File ~/jupyter_dir/jupyter_env/lib/python3.8/site-packages/skl2onnx/common/_container.py:644, in ModelComponentContainer.add_node(self, op_type, inputs, outputs, op_domain, op_version, name, **attrs) 641 node = make_node(op_type, inputs, outputs, name=name, 642 _dtype=dtype, **attrs) 643 except ValueError as e: –> 644 raise ValueError(“Unable to create node ‘{}’ with name=‘{}’.” 645 “”.format(op_type, name)) from e 646 node.domain = op_domain 648 self.node_domain_version_pair_sets.add((op_domain, op_version))
ValueError: Unable to create node ‘TreeEnsembleClassifier’ with name=‘WrappedLightGbmBoosterClassifier’.`
I am unable to figure out why this is happening. Please help to resolve this. Thanks in advance.
Issue Analytics
- State:
- Created a year ago
- Comments:10
I tried the following example and it worked. This issue comes from a feature your tree is using and which is not supported by the converter. Given the error you mention, it might be caused by an unexpected rule in a node (usually only
<
is used).Thanks a lot. The conversion worked. When can we expect this to be pushed into a stable release?