From 215da7626317dc4c278255e4e18648078d3b85ea Mon Sep 17 00:00:00 2001 From: jonibr22 <46603107+jonibr22@users.noreply.github.com> Date: Tue, 24 Sep 2024 04:02:33 +0700 Subject: [PATCH] [R] Fix xgb.model.dt.tree in case where all leaves are negative (#10798) --- 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 36e7af212..db2972da7 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.") }