-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Clean codes for python-package; dump model to JSON #97
Conversation
Hi @wxchan, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
I came across a problem. I add functions as follow: src/c_api.cpp:
python-package/lightgbm/basic.py:
And the output in last line is:
Why this happens? |
@wxchan , the reason is you returning pointer of temporary memory(
I think pre-allocate the buffer in the python is a better solution. But it is hard to decide the buffer len. May be you can pass the buffer len of python as well, and return actual len. |
Fixed with 1st solution. Buffer len is set to 2^20 now, for reference, with num_leaf=15 and num_tree=100, the actual len is around 2^18. |
@guolinke model loaded from file cannot dump to json now(cause segmentation fault), any clue why? |
i think some fields are not loaded from file. e.g. threshold_in_bin_ |
1. merge python-package 2. add dump model to json 3. fix bugs 4. clean code with pylint 5. update python examples
@guolinke I find the reason, to calculate feature importance needs train_data_->feature_names(). I am going to remove feature importance in dumped string for now. |
@wxchan I see. It seems we should load feature_names_ as well when load model from file. |
it seems travis is down... I will merge this after some reviews. |
Used for python or other package to make calculations on model.
I created another branch after Microsoft/python-package, which will be merged into this branch after python-package finished. So you can review this PR after that.
The tree is dumped as tree structure, for example: