I came across an XGBoost out-of-fold prediction callback in a post elsewhere (Get out-of-fold predictions from xgboost.cv in python) and shown below. However, it does not work because it is not in the new callback format introduced with XGBoost 1.6 and results in an error message saying so. I have looked for documentation on upgrading this callback or understanding why it is not in the correct format, but I have not found anything useful. Can someone provide how to update this callback or provide me with some references to do this?
def oof_prediction(): “”" Dirty global variable callback hack. “”"
global cv_prediction_dict def callback(env): """internal function""" cv_prediction_list =  for i in [0, 1, 2, 3, 4]: cv_prediction_list.append([env.cvfolds[i].bst.predict(env.cvfolds[i].dtest)]) cv_prediction_dict['cv'] = cv_prediction_list return callback