[R] Reshape predictions for custom eval metric when they are 2D (#10323)

This commit is contained in:
david-cortes
2024-05-24 11:28:30 +02:00
committed by GitHub
parent 95ba0998b3
commit 5086decb0c
2 changed files with 32 additions and 1 deletions

View File

@@ -213,7 +213,7 @@ xgb.iter.eval <- function(bst, evals, iter, feval) {
res <- sapply(seq_along(evals), function(j) {
w <- evals[[j]]
## predict using all trees
preds <- predict(bst, w, outputmargin = TRUE, iterationrange = "all")
preds <- predict(bst, w, outputmargin = TRUE, reshape = TRUE, iterationrange = "all")
eval_res <- feval(preds, w)
out <- eval_res$value
names(out) <- paste0(evnames[j], "-", eval_res$metric)