From a283f2a97eeaf84978eff79514a6f5842de77407 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Sun, 15 Jan 2023 03:09:08 +0800 Subject: [PATCH] [R] Fix threads used to create DMatrix in predict. (#8681) --- R-package/R/xgb.Booster.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R-package/R/xgb.Booster.R b/R-package/R/xgb.Booster.R index 2f1f5091cdf2..f31c506466f9 100644 --- a/R-package/R/xgb.Booster.R +++ b/R-package/R/xgb.Booster.R @@ -328,8 +328,9 @@ predict.xgb.Booster <- function(object, newdata, missing = NA, outputmargin = FA predleaf = FALSE, predcontrib = FALSE, approxcontrib = FALSE, predinteraction = FALSE, reshape = FALSE, training = FALSE, iterationrange = NULL, strict_shape = FALSE, ...) { object <- xgb.Booster.complete(object, saveraw = FALSE) + if (!inherits(newdata, "xgb.DMatrix")) - newdata <- xgb.DMatrix(newdata, missing = missing) + newdata <- xgb.DMatrix(newdata, missing = missing, nthread = NVL(object$params[["nthread"]], -1)) if (!is.null(object[["feature_names"]]) && !is.null(colnames(newdata)) && !identical(object[["feature_names"]], colnames(newdata)))