Yingjie Zhao
Yingjie Zhao
I guess that was the reason. > [Optimal Split for Categorical Features](https://lightgbm.readthedocs.io/en/latest/Features.html#optimal-split-for-categorical-features): > ... LightGBM sorts the histogram (for a categorical feature) according to its accumulated values (sum_gradient / sum_hessian)...
@jameslamb Really appreciate for your useful advice! I have updated my issue and removed unnecessary code, the newly updated code can be run directly without any modification.
Thanks for the help! I do have found something might be helpful. When I added a ```print(model.best_iteration)``` inside the ```objective``` function, the model's ```best_iteration``` can be printed correctly as it...
Oops. Sorry for the inconvenience! I will delete the double-posted stackflow question right away.
@jmoralez Thanks to your reply. Sorry I might not fully understand. As you said, ```best_model.current_iteration()``` match the best iteration indeed, but I still want to know why invoking ```best_model.best_iteration``` returns...
I tried, but it still not working. ```python best_model_1 = study.best_trial.user_attrs['best_booster'] print('===BEST MODEL 1===') print('Best iteration',best_model_1.best_iteration) print('Current iteration', best_model_1.current_iteration()) print('Memory ID with best_model_1:', id(best_model_1)) best_model_2 = study.user_attrs['best_booster'] print('===BEST MODEL 2===')...
Thank you very much for you patience. Set best iteration inside objective function was a great idea! Actually retrieving the exact value of best iteration was no longer a problem...
Sorry for interrupting your conversation, I think I might found a possible reproducible example without using Optuna. ```python from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.metrics import roc_auc_score...
I just checked the source code of ```__copy__``` and ```__deepcopy__```. https://github.com/microsoft/LightGBM/blob/0c0eb2a6a1ba111f0896dd16a579342fa16f7629/python-package/lightgbm/basic.py#L2841-L2847 Seems like the ```model_to_string``` function doesn't save ```best_iteration``` and invoking ```__init__``` method will reset the booster's ```best_iteration``` to ```-1```...
Thank you for your information. I checked the PR #6101 which related to #5539 but I don't think it will solve this problem as it only changed the way of...