[R] Fix xgb.model.dt.tree in case where all leaves are negative (#10798)

This commit is contained in:
jonibr22
2024-09-24 04:02:33 +07:00
committed by GitHub
parent 19b55b300b
commit 215da76263

View File

@@ -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.")
}