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

Get individual tree depths #2034

Closed
abhishek-ghose opened this issue Mar 1, 2019 · 4 comments
Closed

Get individual tree depths #2034

abhishek-ghose opened this issue Mar 1, 2019 · 4 comments

Comments

@abhishek-ghose
Copy link

Hi,

I am using the Python version of LightGBM (not the sklearn API though). After I have run the train() function with boosting_type='gbdt', is there anyway to get the depths of individual trees? I have the prescribed max_depths; I am interested in the actual depths.

I see that this information is printed out per iteration:
[LightGBM] [Debug] Trained a tree with leaves = 31 and max_depth = 8

But I am unable to locate this information in the object train() returns (checked it in debug mode). Is this information stored only in the C backend? Any means to access it from Python?

Thanks!

@guolinke
Copy link
Collaborator

guolinke commented Mar 1, 2019

set verbose=2

@guolinke guolinke closed this as completed Mar 1, 2019
@abhishek-ghose
Copy link
Author

abhishek-ghose commented Mar 1, 2019

Hi, what attribute of the Python model should I use to access the tree depths? To be clear, I already see it printed - that's not my question; I want to access the depths of each of the trees in the gbm model within my Python code. Is there a way to do that?

@guolinke
Copy link
Collaborator

guolinke commented Mar 1, 2019

@abhishek-ghose
sorry, the depth is not stored in the model content.
I think the simplest solution for your question is, redirecting the log into a file, and get the depths from that.

@abhishek-ghose
Copy link
Author

Got it, thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants