Question: Best practice for early stopping with custom evaluation metric? #12040
-
|
Hi XGBoost team, I’m using XGBoost with a custom evaluation metric and early stopping. I’m a bit unsure about the recommended setup to ensure early stopping is triggered on the intended metric. Environment OS: [Windows 10] xgboost version: [ 2.1.4] Python: [3.11.9] What I tried I pass eval_metric and a custom feval / callback metric. I set early_stopping_rounds=[N] with an evaluation set. Question When both built-in and custom metrics are present, which metric does early stopping use by default? Is the recommended approach to explicitly set the metric ordering / direction (higher is better vs lower is better) for custom metrics? Any pointer to the best-practice docs or examples would be appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
You can use the |
Beta Was this translation helpful? Give feedback.
-
|
Hi, slightly OT, but I need to use the callback for another reason and am perplexed by the following situation:
So how is this solved? Should I set the same value in both places? Because of the second point, early_stopping_rounds is in practice mandatory, but I also need to use the callback. |
Beta Was this translation helpful? Give feedback.
The
early_stopping_roundsis just a convenient parameter for XGBoost to add the early stop callback automatically. If you explicitly pass the call back, then there's no need to specify that parameter.Feel free to make suggestions for improving the document. ;-)