From 87e897f428c069904fd7183b69ed75fce67e1b6c Mon Sep 17 00:00:00 2001 From: Vadim Khotilovich Date: Fri, 6 Jan 2017 15:16:37 -0600 Subject: [PATCH] [R] fix #1903 (#1929) --- R-package/R/xgb.Booster.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R-package/R/xgb.Booster.R b/R-package/R/xgb.Booster.R index 362165c6a..cf428e4e8 100644 --- a/R-package/R/xgb.Booster.R +++ b/R-package/R/xgb.Booster.R @@ -185,6 +185,8 @@ predict.xgb.Booster <- function(object, newdata, missing = NA, newdata <- xgb.DMatrix(newdata, missing = missing) if (is.null(ntreelimit)) ntreelimit <- NVL(object$best_ntreelimit, 0) + if (NVL(object$params[['booster']], '') == 'gblinear') + ntreelimit <- 0 if (ntreelimit < 0) stop("ntreelimit cannot be negative")