Search code examples
pythonxgboost

XGBoost custom formatting for training console outputs


The Python API of XGBoost, by default, displays metrics in the following format to the console during training:

[0] validation_0-mlogloss:6.93514   validation_1-mlogloss:6.98867
[1] validation_0-mlogloss:6.46165   validation_1-mlogloss:6.53638
[2] validation_0-mlogloss:6.12659   validation_1-mlogloss:6.22222
...

I've never found a trace of this in the documentation, but is it possible to use a callback for custom formatting and have the output look more like:

6.93514,6.98867
6.46165,6.53638
6.12659,6.22222

Solution

  • Maybe the callback: xgboost.callback.EvaluationMonitor(rank=0, period=1, show_stdv=False)

    Otherwise, mock/patch() the source code (https://github.com/dmlc/xgboost/blob/master/python-package/xgboost/callback.py)

    I think for the function _fmt_metric