Skip to content

Update Microsoft.ML.LightGbm to use version 3.0 + of LightGbm. #5447

Closed

Description

@gharibkhani
  • Tested on Windows 10 and Server 2019:
  • .NET 4.7:
  • Microsoft.ML (1.5.2)
  • Microsoft.ML.LightGbm (1.5.2)
  • LightGbm (3.0.0)

Issue
It crashes in this line

  • var model = pipeline.Fit(trainData);

  • I get this error: System.InvalidOperationException: 'LightGBM Error, code is -1, error message is 'Unknown importance type: only support split=0 and gain=1'.'

This error can be reproduced by an example. I just used the example in docs.microsoft.com and able to reproduce it.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.lightgbmextensions.lightgbm?view=ml-dotnet

I created a console app and you can access it from the link below:

https://drive.google.com/drive/folders/1-wc04CM75-IGoxjRAniDuhqI-zrHTWwM?usp=sharing

I talked to the LightGBM team and they mentioned this issue exists in .Net code and not theirs. This is the third time this issue has been reported (#5431 and #5382) and each time it has been closed without any resolution.

Activity

  1. self-assigned this
    on Oct 22, 2020
  2. mstfbl commented on Oct 22, 2020

    @mstfbl
    Contributor

    Hi @gharibkhani ,

    As I said in issue #5431, I copied the code you've attached in your repro, put it in a new console project, installed the Microsoft.ML (1.5.2) and Microsoft.ML.LightGbm (1.5.2) NuGet packages, and tried to reproduce your issue, but your code passed successfully. I also attached that exact same project in my comment here.

    I also tried the exact same project you've attached, and saw that I get exact same exception of Unknown importance type: only support split=0 and gain=1.. However, I do not get this exception without the LightGBM 3.0.0 package.

    Did you try to run this repro project I attached in my last comment and see if this passed on your computer? It works on mine. If it also runs on yours, the problem must be in the LightGBM 3.0.0 project you've added. This is indeed the case, as I have even found the exact source of this error, in LightGBM's code here. This means that this issue is stemming from this LightGBM 3.0.0 package, and not from ML.NET.

    If there is anything else I can offer my assistance with, please let me know. Thanks.

  3. gharibkhani commented on Oct 22, 2020

    @gharibkhani
    Author

    @mstfbl

    Thank you so much for getting back to this conversion.
    Yes, as you said before, everything works if I use LightGBM 2.3.1 and I am using it in my project right now and do not have any problem. But the new version has a lot of good improvements which is going to be a great improvement in my project.
    You are right about the place that it returns the exception as well but I read the code found out they introduce some new parameters that do not accept the default value anymore. I believe the new parameter is saved_feature_importance_type but I could not find a way to pass this value.

  4. gharibkhani commented on Oct 22, 2020

    @gharibkhani
    Author

    @mstfbl
    I looked at the code to see where do we need the change and found this:

    LGBM_BoosterSaveModelToString has 7 parameters in v3.0 but in our side (here) it has 6 parameters

    At the side research, I checked the other APIs calls to see if there is any discrepancy and found these:

    1. LGBM_AllocateArray, LGBM_CopyToArray and LGBM_FreeArray are not exist in lib_lightgbm anymore.
    2. LGBM_DatasetSetField call has a parameter "type" which is CApiDType on the .net wrapper but it is int on lib_lightgbm.
    3. LGBM_BoosterPredictForMat has two discrepancies:
      • Parameter dataType is CApiDType on the .net wrapper but it is int on lib_lightgbm.
      • Parameter outLen is int on the .net wrapper but it is int64 on lib_lightgbm.

    Hopefully, these can help with your research.

  5. mstfbl commented on Oct 28, 2020

    @mstfbl
    Contributor

    Hey @gharibkhani ,

    Thank you for your kind summary on the changes from LightGBM v2.3.1 to v3.0. For ML.NET to support LightGBM v3.0, we will need to make significant changes to Microsoft.ML.LightGBM. I have marked this issue as a feature request for the time being. In the meantime, the LightGBM version that ML.NET supports is v2.3.1.

  6. removed their assignment
    on Oct 30, 2020
  7. sergey-tihon commented on Dec 29, 2020

    @sergey-tihon

    If this is not planned for near future, would be nice to release new version of Microsoft.ML.LightGBM with constrain for upper bound of LightGBM (>= 2.2.3 && < 3.0.0)

  8. changed the title [-]System.InvalidOperationException: 'LightGBM Error, code is -1 (LightGbm 3.0.0)[/-] [+]Update Microsoft.ML.LightGbm to use version 3.0 + of LightGbm.[/+] on Jun 23, 2021
  9. ericstj commented on Dec 5, 2023

    @ericstj
    Member

    @michaelgsharp can we close this one now that #6880 is in?

  10. luisquintanilla commented on Dec 7, 2023

    @luisquintanilla
    Contributor

    released in Ml.NET 3.0

  11. locked and limited conversation to collaborators on Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions