Skip to content

Commit 76bdca0

Browse files
authored
[R] Fix threads used to create DMatrix in predict. (dmlc#8681) (dmlc#8682)
1 parent 021e6a8 commit 76bdca0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R-package/R/xgb.Booster.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ predict.xgb.Booster <- function(object, newdata, missing = NA, outputmargin = FA
328328
predleaf = FALSE, predcontrib = FALSE, approxcontrib = FALSE, predinteraction = FALSE,
329329
reshape = FALSE, training = FALSE, iterationrange = NULL, strict_shape = FALSE, ...) {
330330
object <- xgb.Booster.complete(object, saveraw = FALSE)
331+
331332
if (!inherits(newdata, "xgb.DMatrix"))
332-
newdata <- xgb.DMatrix(newdata, missing = missing)
333+
newdata <- xgb.DMatrix(newdata, missing = missing, nthread = NVL(object$params[["nthread"]], -1))
333334
if (!is.null(object[["feature_names"]]) &&
334335
!is.null(colnames(newdata)) &&
335336
!identical(object[["feature_names"]], colnames(newdata)))

0 commit comments

Comments
 (0)