From 95623cf5fb3a3bca34be3facdc3fa7e463cd3e37 Mon Sep 17 00:00:00 2001 From: jonibr22 <46603107+jonibr22@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:17:38 +0700 Subject: [PATCH] fix xgb.model.dt.tree in case where all leaves have negative value --- R-package/R/xgb.model.dt.tree.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/R/xgb.model.dt.tree.R b/R-package/R/xgb.model.dt.tree.R index 36e7af212a51..db2972da7513 100644 --- a/R-package/R/xgb.model.dt.tree.R +++ b/R-package/R/xgb.model.dt.tree.R @@ -89,7 +89,7 @@ xgb.model.dt.tree <- function(model = NULL, text = NULL, from_text <- FALSE } - if (length(text) < 2 || !any(grepl('leaf=(\\d+)', text))) { + if (length(text) < 2 || !any(grepl('leaf=(-?\\d+)', text))) { stop("Non-tree model detected! This function can only be used with tree models.") }