From 79c9821cae84e5c5c4a7e980aca99537b5d547df Mon Sep 17 00:00:00 2001 From: fis Date: Tue, 11 Jan 2022 01:05:49 +0800 Subject: [PATCH] R doc. --- R-package/R/xgb.load.R | 2 +- R-package/demo/basic_walkthrough.R | 2 +- R-package/tests/testthat/test_io.R | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R-package/R/xgb.load.R b/R-package/R/xgb.load.R index a85651f0b4ca..d98041908eb4 100644 --- a/R-package/R/xgb.load.R +++ b/R-package/R/xgb.load.R @@ -5,7 +5,7 @@ #' @param modelfile the name of the binary input file. #' #' @details -#' The input file is expected to contain a model saved in an xgboost-internal binary format +#' The input file is expected to contain a model saved in an xgboost model format #' using either \code{\link{xgb.save}} or \code{\link{cb.save.model}} in R, or using some #' appropriate methods from other xgboost interfaces. E.g., a model trained in Python and #' saved from there in xgboost format, could be loaded from R. diff --git a/R-package/demo/basic_walkthrough.R b/R-package/demo/basic_walkthrough.R index 6c7f79a03f26..31f79fb57be4 100644 --- a/R-package/demo/basic_walkthrough.R +++ b/R-package/demo/basic_walkthrough.R @@ -63,7 +63,7 @@ print(paste("sum(abs(pred2-pred))=", sum(abs(pred2 - pred)))) # save model to R's raw vector raw <- xgb.save.raw(bst) # load binary model to R -bst3 <- xgb.load(raw) +bst3 <- xgb.load.raw(raw) pred3 <- predict(bst3, test$data) # pred3 should be identical to pred print(paste("sum(abs(pred3-pred))=", sum(abs(pred3 - pred)))) diff --git a/R-package/tests/testthat/test_io.R b/R-package/tests/testthat/test_io.R index 735c06076422..f4990352f414 100644 --- a/R-package/tests/testthat/test_io.R +++ b/R-package/tests/testthat/test_io.R @@ -1,10 +1,10 @@ -context('Test model IO.') +context("Test model IO.") ## some other tests are in test_basic.R require(xgboost) require(testthat) -data(agaricus.train, package = 'xgboost') -data(agaricus.test, package = 'xgboost') +data(agaricus.train, package = "xgboost") +data(agaricus.test, package = "xgboost") train <- agaricus.train test <- agaricus.test @@ -22,6 +22,7 @@ test_that("load/save raw works", { from_json <- xgb.load.raw(json_bytes) from_ubj <- xgb.load.raw(ubj_bytes) + ## FIXME(jiamingy): Should we include these 3 lines into `xgb.load.raw`? from_json <- list(handle = from_json, raw = NULL) class(from_json) <- "xgb.Booster" from_json <- xgb.Booster.complete(from_json, saveraw = TRUE)