-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Confused about 2^max_depth > num_leaves warning #5734
Comments
can you explain why only 16 leaves can be there if max depth is set to 4 |
"depth" begins at 0 (a 0-split tree has depth=0). LightGBM creates binary splits (the data is partitioned into exactly 2 groups by each split). LightGBM grows non-symmetric trees. These constraints describe why, when ![]() You could try changing the parameters import lightgbm as lgb
from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=10_000, n_features=1, centers=2)
bst = lgb.train(
params={
"objective": "binary",
"max_depth": 1,
"num_iterations": 1,
"verbose": 1
},
train_set=lgb.Dataset(X, label=y, params={"min_data_in_bin": 1})
)
bst_df = bst.trees_to_dataframe()
Sorry for this, yes it is misleading. Please see the discussion in #2898 (comment) ... I'll put up a PR to modify this warning and clarify the documentation. |
I followed the parameter tuning guide at https://lightgbm.readthedocs.io/en/latest/Parameters-Tuning.html, which says
However, when I set max_leaves = 31 and max_depth = 8 explictly, I keep getting the warning message:
The warnings actually do not make sense since num_leaves = 31 is good enough for my model and I set max_depth = 7,8,9 to prevent overfitting. For example, if I follow the warning message and set max_depth = 4, in my opinion max_depth is no longer a valid hyperparameter since only 16 leaves can be grown.
I really wonder if I misunderstand something in your manual or the warning itself is misleading. I am looking forward to your reply.
Thanks.
The text was updated successfully, but these errors were encountered: