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
When trying to run onnxmltools.convert_lightgbm on a lightgbm.sklearn.LGBMRegressor model with objective='poisson', the conversion fails with a RuntimeError.
Open PR
This is an update. O just saw this pull request. By directly applying the change it works properly. I would really recommend approving and merge the PR. :)
Similar closed issue
This problem seems to be similar to this one, reported by @janjagusch. I could not reproduce the workaround for the original (poisson) problem.
Reproducible example
import numpy as np
from lightgbm.sklearn import LGBMRegressor
from onnxmltools import convert_lightgbm
from skl2onnx.common.data_types import FloatTensorType
examples = 1000
features = 10
X = np.random.randn(examples, features)
y = np.round(np.random.randn(examples), 0)
model = LGBMRegressor(objective="quantile", metric="quantile", alpha=0.05)
model.fit(X, y)
initial_types = [("float_input", FloatTensorType([None, features]))]
onnx_model = convert_lightgbm(model, initial_types=initial_types)
Results in the following error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_33543/973951346.py in <module>
14
15 initial_types = [("float_input", FloatTensorType([None, features]))]
---> 16 onnx_model = convert_lightgbm(model, initial_types=initial_types)
/media/bruno/dados/dev/virtual_envs/generic_env/lib/python3.9/site-packages/onnxmltools/convert/main.py in convert_lightgbm(model, name, initial_types, doc_string, target_opset, targeted_onnx, custom_conversion_functions, custom_shape_calculators, without_onnx_ml, zipmap)
134
135 from .lightgbm.convert import convert
--> 136 return convert(model, name, initial_types, doc_string, target_opset, targeted_onnx,
137 custom_conversion_functions, custom_shape_calculators, without_onnx_ml,
138 zipmap=zipmap)
/media/bruno/dados/dev/virtual_envs/generic_env/lib/python3.9/site-packages/onnxmltools/convert/lightgbm/convert.py in convert(model, name, initial_types, doc_string, target_opset, targeted_onnx, custom_conversion_functions, custom_shape_calculators, without_onnx_ml, zipmap)
54 custom_shape_calculators, zipmap=zipmap)
55 topology.compile()
---> 56 onnx_ml_model = convert_topology(topology, name, doc_string, target_opset, targeted_onnx)
57
58 if without_onnx_ml:
/media/bruno/dados/dev/virtual_envs/generic_env/lib/python3.9/site-packages/onnxconverter_common/topology.py in convert_topology(topology, model_name, doc_string, target_opset, targeted_onnx, channel_first_inputs)
774 else:
775 # Convert the selected operator into some ONNX objects and save them into the container
--> 776 get_converter(operator.type)(scope, operator, container)
777
778 # When calling ModelComponentContainer's add_initializer(...), nothing is added into the input list.
/media/bruno/dados/dev/virtual_envs/generic_env/lib/python3.9/site-packages/onnxmltools/convert/lightgbm/operator_converters/LightGbm.py in convert_lightgbm(scope, operator, container)
398 post_transform = "Exp"
399 else:
--> 400 raise RuntimeError(
401 "LightGBM objective should be cleaned already not '{}'.".format(
402 gbm_text['objective']))
RuntimeError: LightGBM objective should be cleaned already not 'quantile'.
Issue description
When trying to run
onnxmltools.convert_lightgbm
on alightgbm.sklearn.LGBMRegressor
model withobjective='poisson'
, the conversion fails with a RuntimeError.Open PR
This is an update. O just saw this pull request. By directly applying the change it works properly. I would really recommend approving and merge the PR. :)
Similar closed issue
This problem seems to be similar to this one, reported by @janjagusch. I could not reproduce the workaround for the original (poisson) problem.
Reproducible example
Results in the following error:
Versions
The text was updated successfully, but these errors were encountered: