microsoft / LightGBM

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.
https://lightgbm.readthedocs.io/en/latest/
MIT License
16.65k stars 3.83k forks source link

Modifying model file #3230

Closed kobics closed 4 years ago

kobics commented 4 years ago

Hi We would like to modify a model file, but few things seems wrong. 1 When we modify shrinkage/leaf values, and load, sometime the kernel dies 2 When we modify the shrinkage, and load the model (And the kernel does not die), the predictions are the same as the original model, before modifying the shrinkage

Thanks

jameslamb commented 4 years ago

Hi @kobics , thanks for using LightGBM! If you can please provide some more information, an appropriate maintainer will help you.

Can you please answer the questions you were asked when you clicked "New issue"? Copy this content (https://raw.githubusercontent.com/microsoft/LightGBM/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md) and fill it out in a comment here.

guolinke commented 4 years ago

@kobics if you change the model file manually, you should remove tree_size field.

kobics commented 4 years ago

https://raw.githubusercontent.com/microsoft/LightGBM/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md

kobics commented 4 years ago

Hi @kobics , thanks for using LightGBM! If you can please provide some more information, an appropriate maintainer will help you.

Can you please answer the questions you were asked when you clicked "New issue"? Copy this content (https://raw.githubusercontent.com/microsoft/LightGBM/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md) and fill it out in a comment here.

Hi @jameslamb thanks for your reply. please explain what you ask me Thanks

jameslamb commented 4 years ago

it looks like you opened #3232 with the details I'm asking for. That wasn't my intention, but that works!

did @guolinke 's suggestion (https://github.com/microsoft/LightGBM/issues/3232#issuecomment-659409428) help you?

kobics commented 4 years ago

@kobics if you change the model file manually, you should remove tree_size field.

works for the leafs (at this point), when i change the shrinkage and load, it still breaks

kobics commented 4 years ago

it looks like you opened #3232 with the details I'm asking for. That wasn't my intention, but that works!

did @guolinke 's suggestion (#3232 (comment)) help you?

partially :

works for the leafs (at this point), when i change the shrinkage and load, it still breaks

jameslamb commented 4 years ago

Ok I've reopend this issue. Let's keep the conversation here and not use #3232 , so it is one conversation.

From #232 , it looks like you are using version 2.3.0 of the Python package. That version is quite old...could you try installing version 2.3.1 from PyPi (pip install lightgbm) or building from source in this repo?

If you need to be on 2.3.0 for stability reasons (totally understand!), is it possible to provide the model file here and the code that you are using to load it?

Python maintainers like @StrikerRUS will be able to be more helpful, but we need more information than what you've provided so far to give you the best possible help.

guolinke commented 4 years ago

@kobics what do "break" mean? it dies?

2 When we modify the shrinkage, and load the model (And the kernel does not die), the predictions are the same as the original model, before modifying the shrinkage

The shrinkage rate is not used in prediction time. The leaf value is already shrinkage in training. It will not apply again.

kobics commented 4 years ago

@kobics what do "break" mean? it dies?

2 When we modify the shrinkage, and load the model (And the kernel does not die), the predictions are the same as the original model, before modifying the shrinkage

The shrinkage rate is not used in prediction time. The leaf value is already shrinkage in training. It will not apply again.

@guolinke Thanks this is very helpful. Can you tell me if there additional parts of the model I can erase and still be able to : 1 load and predict 2 load and continue to train

Thank you

guolinke commented 4 years ago

@kobics For the tree model, you can edit tree structure and tree outputs (but need to remove the tree_size). For the most remaining fields in tree, there are to record the status in training.

kobics commented 4 years ago

@kobics For the tree model, you can edit tree structure and tree outputs (but need to remove the tree_size). For the most remaining fields in tree, there are to record the status in training.

@guolinke Thanks. is the status recorded used for later training (if we use it as an init model)?

guolinke commented 4 years ago

@kobics I don't think so.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.