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

Define best_iteration only if early stopping is used. #9403

Merged
merged 3 commits into from
Jul 24, 2023

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Jul 20, 2023

This is the behavior specified by the document but not honored in the actual code. The improvement calculated in early stopping is a bit more complicated than regular monitoring as it has options like min_delta. Leaving it to early stopping to prevent inconsistent behaviors.

  • Don't set the attributes if there's no early stopping.
  • Cleanup the code for callbacks and replace assertions with proper exceptions.
  • Assign the attributes when early stopping save_best is used.
  • Turn the attributes into Python properties.

Close #8880 .

This is the behavior specified by the document but not honored in actual code.

- Don't set the attributes if there's no early stopping.
- Cleanup the code for callbacks, replace assertions with proper exceptions.
- Assign the attributes when early stopping `save_best` is used.
- Turn the attributes into Python properties.
python-package/xgboost/sklearn.py Outdated Show resolved Hide resolved
python-package/xgboost/sklearn.py Outdated Show resolved Hide resolved
python-package/xgboost/sklearn.py Outdated Show resolved Hide resolved
tests/python/test_callback.py Outdated Show resolved Hide resolved
Co-authored-by: Philip Hyunsu Cho <[email protected]>
@trivialfis
Copy link
Member Author

@hcho3 All changes applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Property best_iteration not reflecting the best iteration when trained without early stopping
2 participants