Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting LightGBM Regressor to ONNX seems impossible with mixed float and string initital_types. #696

Open
flaussy opened this issue Jun 20, 2024 · 1 comment
Assignees

Comments

@flaussy
Copy link

flaussy commented Jun 20, 2024

Hi,

I'm trying to convert a Light GBMRegressor using the convert_lightgbm function.
I am using a mix of categorical (string) and float values.

However, when I try to specify differerent initial_types, I get this error :

RuntimeError: For operator LgbmRegressor (type: LgbmRegressor), at most 1 input(s) is(are) supported but we got 15 input(s) which are ['postal_code_mission', 'do_code', 'dz_code', 'agency_code', 'adecco_code', 'siret', 'cod_prs_prc', 'cod_zep_ctr', 'cod_sgm_tt_con', 'depenses_client', 'month', 'hourly_rate', 'contract_duration', 'tension', 'difficulty']

I think it means I can only specify one input, so it has to be either float or string but can't be both ?

I tried doing :

initial_type = [('float_input', FloatTensorType([None, X_train.shape[1]]))]

# Convert the LightGBM model to ONNX format
onnx_model = onnxmltools.convert_lightgbm(model, initial_types=initial_type)

It worked for the conversion, but when in inference I got this error :

InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (tensor(string)) , expected: (tensor(float))

Wich makes sense since I'm passing string to something that expect floats ...

Am I doing something wrong or is there no way to convert a LGBMRegressor in onnx format with both string and float tensor ?

@xadupre xadupre self-assigned this Jun 21, 2024
@ogencoglu
Copy link

Any updates here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants