mlprodict icon indicating copy to clipboard operation
mlprodict copied to clipboard

ImportError: cannot import name 'FEATURE_IMPORTANCE_TYPE_MAPPER' from 'lightgbm.basic'

Open fhaque opened this issue 1 year ago • 4 comments

This issue is caused when my poetry lock file was updated with lightgbm == 4.0.0. The relevant lightgbm issue is: https://github.com/microsoft/LightGBM/pull/5654 which updated FEATURE_IMPORTANCE_TYPE_MAPPER to _FEATURE_IMPORTANCE_TYPE_MAPPER.

This then affected the line https://github.com/sdpython/mlprodict/blame/27d6da4ecdd76e18292f265fde61d19b66937a5c/mlprodict/onnx_conv/helpers/lgbm_helper.py#L84

Maybe the solution here is to fix the dependency on LightGBM? ie. update https://github.com/sdpython/mlprodict/blob/27d6da4ecdd76e18292f265fde61d19b66937a5c/setup.py#L485 with <4.0.0?

fhaque avatar Aug 01 '23 17:08 fhaque

@fhaque Hello. Do you have the fix for this?

nitish20899 avatar Sep 26 '23 20:09 nitish20899

Not yet. The fix will be done in onnxmltools. The documentation of sklearn-onnx has been update to reflect that: https://onnx.ai/sklearn-onnx/auto_tutorial/plot_gexternal_lightgbm.html.

xadupre avatar Oct 02 '23 16:10 xadupre

Hi, Any updates on this. I am experiencing the very same issue

Vignesh-95 avatar Oct 19 '23 10:10 Vignesh-95

If you cannot wait for the official releases of skl2onnx (v1.16.0) and onnxmltools (1.11.3), you can install them directly from GitHub:

pip install --upgrade git+https://github.com/onnx/sklearn-onnx.git
pip install --upgrade git+https://github.com/onnx/onnxmltools

or with the commits I tested that currently work:

pip install --upgrade git+https://github.com/onnx/sklearn-onnx.git@943cac213812a5ead520ac1edbbc5ddfa0fbb900
pip install --upgrade git+https://github.com/onnx/onnxmltools@19847127edd283dc0140e3fc5ec23e25a1f6dca6

janvdp avatar Nov 26 '23 19:11 janvdp