зеркало из https://github.com/microsoft/LightGBM.git
[R-package] move all examples to dontrun() to fix R CMD CHECK notes (#3270)
* Move all examples to dontrun * update docs * fix nested dontrun * remove :: in examples * run_dontrun in pkgdown Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
This commit is contained in:
Родитель
6f54ec3db3
Коммит
c454d5f8cc
|
@ -173,6 +173,7 @@ check_succeeded="yes"
|
|||
(
|
||||
R CMD check ${PKG_TARBALL} \
|
||||
--as-cran \
|
||||
--run-dontrun \
|
||||
|| check_succeeded="no"
|
||||
) &
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ if ($env:COMPILER -ne "MSVC") {
|
|||
}
|
||||
|
||||
Write-Output "Running R CMD check as CRAN"
|
||||
Run-R-Code-Redirect-Stderr "result <- processx::run(command = 'R.exe', args = c('CMD', 'check', '--no-multiarch', '--as-cran', '$PKG_FILE_NAME'), echo = TRUE, windows_verbatim_args = FALSE)" ; $check_succeeded = $?
|
||||
Run-R-Code-Redirect-Stderr "result <- processx::run(command = 'R.exe', args = c('CMD', 'check', '--no-multiarch', '--as-cran', '--run-dontrun', '$PKG_FILE_NAME'), echo = TRUE, windows_verbatim_args = FALSE)" ; $check_succeeded = $?
|
||||
|
||||
Write-Output "R CMD check build logs:"
|
||||
$INSTALL_LOG_FILE_NAME = "lightgbm.Rcheck\00install.out"
|
||||
|
|
|
@ -718,6 +718,7 @@ Booster <- R6::R6Class(
|
|||
#' number of columns corresponding to the number of trees.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -735,6 +736,7 @@ Booster <- R6::R6Class(
|
|||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' preds <- predict(model, test$data)
|
||||
#' }
|
||||
#' @export
|
||||
predict.lgb.Booster <- function(object,
|
||||
data,
|
||||
|
@ -774,7 +776,7 @@ predict.lgb.Booster <- function(object,
|
|||
#' @return lgb.Booster
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -834,7 +836,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
|
|||
#' @return lgb.Booster
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' library(lightgbm)
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
@ -882,7 +884,7 @@ lgb.save <- function(booster, filename, num_iteration = NULL) {
|
|||
#' @return json format of model
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' library(lightgbm)
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
@ -930,6 +932,7 @@ lgb.dump <- function(booster, num_iteration = NULL) {
|
|||
#' @return vector of evaluation result
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' # train a regression model
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
@ -956,6 +959,7 @@ lgb.dump <- function(booster, num_iteration = NULL) {
|
|||
#'
|
||||
#' # Get L2 values for "test" dataset
|
||||
#' lgb.get.eval.result(model, "test", "l2")
|
||||
#' }
|
||||
#' @export
|
||||
lgb.get.eval.result <- function(booster, data_name, eval_name, iters = NULL, is_err = FALSE) {
|
||||
|
||||
|
|
|
@ -725,6 +725,7 @@ Dataset <- R6::R6Class(
|
|||
#' @return constructed dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -732,7 +733,7 @@ Dataset <- R6::R6Class(
|
|||
#' lgb.Dataset.save(dtrain, data_file)
|
||||
#' dtrain <- lgb.Dataset(data_file)
|
||||
#' lgb.Dataset.construct(dtrain)
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
lgb.Dataset <- function(data,
|
||||
params = list(),
|
||||
|
@ -770,13 +771,14 @@ lgb.Dataset <- function(data,
|
|||
#' @return constructed dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
lgb.Dataset.create.valid <- function(dataset, data, info = list(), ...) {
|
||||
|
||||
|
@ -796,11 +798,12 @@ lgb.Dataset.create.valid <- function(dataset, data, info = list(), ...) {
|
|||
#' @param dataset Object of class \code{lgb.Dataset}
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
#' lgb.Dataset.construct(dtrain)
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
lgb.Dataset.construct <- function(dataset) {
|
||||
|
||||
|
@ -826,6 +829,7 @@ lgb.Dataset.construct <- function(dataset) {
|
|||
#' be directly used with an \code{lgb.Dataset} object.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -833,7 +837,7 @@ lgb.Dataset.construct <- function(dataset) {
|
|||
#' stopifnot(nrow(dtrain) == nrow(train$data))
|
||||
#' stopifnot(ncol(dtrain) == ncol(train$data))
|
||||
#' stopifnot(all(dim(dtrain) == dim(train$data)))
|
||||
#'
|
||||
#' }
|
||||
#' @rdname dim
|
||||
#' @export
|
||||
dim.lgb.Dataset <- function(x, ...) {
|
||||
|
@ -860,6 +864,7 @@ dim.lgb.Dataset <- function(x, ...) {
|
|||
#' Since row names are irrelevant, it is recommended to use \code{colnames} directly.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -868,7 +873,7 @@ dim.lgb.Dataset <- function(x, ...) {
|
|||
#' colnames(dtrain)
|
||||
#' colnames(dtrain) <- make.names(seq_len(ncol(train$data)))
|
||||
#' print(dtrain, verbose = TRUE)
|
||||
#'
|
||||
#' }
|
||||
#' @rdname dimnames.lgb.Dataset
|
||||
#' @export
|
||||
dimnames.lgb.Dataset <- function(x) {
|
||||
|
@ -932,6 +937,7 @@ dimnames.lgb.Dataset <- function(x) {
|
|||
#' @return constructed sub dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -939,7 +945,7 @@ dimnames.lgb.Dataset <- function(x) {
|
|||
#' dsub <- lightgbm::slice(dtrain, seq_len(42L))
|
||||
#' lgb.Dataset.construct(dsub)
|
||||
#' labels <- lightgbm::getinfo(dsub, "label")
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
slice <- function(dataset, ...) {
|
||||
UseMethod("slice")
|
||||
|
@ -978,6 +984,7 @@ slice.lgb.Dataset <- function(dataset, idxset, ...) {
|
|||
#' }
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -988,7 +995,7 @@ slice.lgb.Dataset <- function(dataset, idxset, ...) {
|
|||
#'
|
||||
#' labels2 <- lightgbm::getinfo(dtrain, "label")
|
||||
#' stopifnot(all(labels2 == 1 - labels))
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
getinfo <- function(dataset, ...) {
|
||||
UseMethod("getinfo")
|
||||
|
@ -1031,6 +1038,7 @@ getinfo.lgb.Dataset <- function(dataset, name, ...) {
|
|||
#' }
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -1041,7 +1049,7 @@ getinfo.lgb.Dataset <- function(dataset, name, ...) {
|
|||
#'
|
||||
#' labels2 <- lightgbm::getinfo(dtrain, "label")
|
||||
#' stopifnot(all.equal(labels2, 1 - labels))
|
||||
#'
|
||||
#' }
|
||||
#' @export
|
||||
setinfo <- function(dataset, ...) {
|
||||
UseMethod("setinfo")
|
||||
|
@ -1071,6 +1079,7 @@ setinfo.lgb.Dataset <- function(dataset, name, info, ...) {
|
|||
#' @return passed dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -1078,7 +1087,7 @@ setinfo.lgb.Dataset <- function(dataset, name, info, ...) {
|
|||
#' lgb.Dataset.save(dtrain, data_file)
|
||||
#' dtrain <- lgb.Dataset(data_file)
|
||||
#' lgb.Dataset.set.categorical(dtrain, 1L:2L)
|
||||
#'
|
||||
#' }
|
||||
#' @rdname lgb.Dataset.set.categorical
|
||||
#' @export
|
||||
lgb.Dataset.set.categorical <- function(dataset, categorical_feature) {
|
||||
|
@ -1102,6 +1111,7 @@ lgb.Dataset.set.categorical <- function(dataset, categorical_feature) {
|
|||
#' @return passed dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package ="lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -1109,7 +1119,7 @@ lgb.Dataset.set.categorical <- function(dataset, categorical_feature) {
|
|||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset(test$data, test = train$label)
|
||||
#' lgb.Dataset.set.reference(dtest, dtrain)
|
||||
#'
|
||||
#' }
|
||||
#' @rdname lgb.Dataset.set.reference
|
||||
#' @export
|
||||
lgb.Dataset.set.reference <- function(dataset, reference) {
|
||||
|
@ -1133,10 +1143,12 @@ lgb.Dataset.set.reference <- function(dataset, reference) {
|
|||
#' @return passed dataset
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
#' lgb.Dataset.save(dtrain, tempfile(fileext = ".bin"))
|
||||
#' }
|
||||
#' @export
|
||||
lgb.Dataset.save <- function(dataset, fname) {
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#' for input in \code{lgb.Dataset}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(iris)
|
||||
#'
|
||||
#' str(iris)
|
||||
|
@ -19,11 +20,10 @@
|
|||
#' # Convert all factors/chars to integer
|
||||
#' str(lgb.convert(data = iris))
|
||||
#'
|
||||
#' \dontrun{
|
||||
#' # When lightgbm package is installed, and you do not want to load it
|
||||
#' # You can still use the function!
|
||||
#' lgb.unloader()
|
||||
#' str(lightgbm::lgb.convert(data = iris))
|
||||
#' str(lgb.convert(data = iris))
|
||||
#' # 'data.frame': 150 obs. of 5 variables:
|
||||
#' # $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
|
||||
#' # $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
|
||||
|
@ -31,7 +31,6 @@
|
|||
#' # $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
|
||||
#' # $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
|
||||
#' }
|
||||
#'
|
||||
#' @export
|
||||
lgb.convert <- function(data) {
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#' \code{lgb.Dataset}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(iris)
|
||||
#'
|
||||
#' str(iris)
|
||||
|
@ -48,7 +49,7 @@
|
|||
#' )
|
||||
#' newest_iris <- lgb.convert_with_rules(data = iris, rules = personal_rules)
|
||||
#' str(newest_iris$data) # SUCCESS!
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom data.table set
|
||||
#' @export
|
||||
lgb.convert_with_rules <- function(data, rules = NULL) {
|
||||
|
|
|
@ -56,6 +56,7 @@ CVBooster <- R6::R6Class(
|
|||
#' @return a trained model \code{lgb.CVBooster}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -68,6 +69,7 @@ CVBooster <- R6::R6Class(
|
|||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' }
|
||||
#' @importFrom data.table data.table setorderv
|
||||
#' @export
|
||||
lgb.cv <- function(params = list()
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#' }
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -32,7 +33,7 @@
|
|||
#'
|
||||
#' tree_imp1 <- lgb.importance(model, percentage = TRUE)
|
||||
#' tree_imp2 <- lgb.importance(model, percentage = FALSE)
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom data.table := setnames setorderv
|
||||
#' @export
|
||||
lgb.importance <- function(model, percentage = TRUE) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#' Contribution columns to each class.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' Logit <- function(x) log(x / (1.0 - x))
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
@ -38,7 +39,7 @@
|
|||
#' )
|
||||
#'
|
||||
#' tree_interpretation <- lgb.interprete(model, test$data, 1L:5L)
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom data.table as.data.table
|
||||
#' @export
|
||||
lgb.interprete <- function(model,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#' }
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -44,7 +44,7 @@
|
|||
#' model <- lgb.train(params, dtrain, 10L)
|
||||
#'
|
||||
#' tree_dt <- lgb.model.dt.tree(model)
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom data.table := rbindlist
|
||||
#' @importFrom jsonlite fromJSON
|
||||
#' @export
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#' and silently returns a processed data.table with \code{top_n} features sorted by defined importance.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -37,6 +38,7 @@
|
|||
#'
|
||||
#' tree_imp <- lgb.importance(model, percentage = TRUE)
|
||||
#' lgb.plot.importance(tree_imp, top_n = 5L, measure = "Gain")
|
||||
#' }
|
||||
#' @importFrom graphics barplot par
|
||||
#' @export
|
||||
lgb.plot.importance <- function(tree_imp,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#' The \code{lgb.plot.interpretation} function creates a \code{barplot}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' Logit <- function(x) {
|
||||
#' log(x / (1.0 - x))
|
||||
#' }
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#' @return a trained booster model \code{lgb.Booster}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -46,6 +47,7 @@
|
|||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 3L
|
||||
#' )
|
||||
#' }
|
||||
#' @export
|
||||
lgb.train <- function(params = list(),
|
||||
data,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#' @return NULL invisibly.
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -31,7 +32,6 @@
|
|||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#'
|
||||
#' \dontrun{
|
||||
#' lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
|
||||
#' rm(model, dtrain, dtest) # Not needed if wipe = TRUE
|
||||
#' gc() # Not needed if wipe = TRUE
|
||||
|
@ -39,7 +39,6 @@
|
|||
#' library(lightgbm)
|
||||
#' # Do whatever you want again with LightGBM without object clashing
|
||||
#' }
|
||||
#'
|
||||
#' @export
|
||||
lgb.unloader <- function(restore = TRUE, wipe = FALSE, envir = .GlobalEnv) {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#' @return \code{lgb.Booster}.
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' library(lightgbm)
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#' @return NULL invisibly.
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' \dontrun{
|
||||
#' library(lightgbm)
|
||||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
|
|
|
@ -22,6 +22,7 @@ Note: since \code{nrow} and \code{ncol} internally use \code{dim}, they can also
|
|||
be directly used with an \code{lgb.Dataset} object.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -29,5 +30,5 @@ dtrain <- lgb.Dataset(train$data, label = train$label)
|
|||
stopifnot(nrow(dtrain) == nrow(train$data))
|
||||
stopifnot(ncol(dtrain) == ncol(train$data))
|
||||
stopifnot(all(dim(dtrain) == dim(train$data)))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ Generic \code{dimnames} methods are used by \code{colnames}.
|
|||
Since row names are irrelevant, it is recommended to use \code{colnames} directly.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -32,5 +33,5 @@ dimnames(dtrain)
|
|||
colnames(dtrain)
|
||||
colnames(dtrain) <- make.names(seq_len(ncol(train$data)))
|
||||
print(dtrain, verbose = TRUE)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ The \code{name} field can be one of the following:
|
|||
}
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -43,5 +44,5 @@ lightgbm::setinfo(dtrain, "label", 1 - labels)
|
|||
|
||||
labels2 <- lightgbm::getinfo(dtrain, "label")
|
||||
stopifnot(all(labels2 == 1 - labels))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ Construct \code{lgb.Dataset} object from dense matrix, sparse matrix
|
|||
or local file (that was created previously by saving an \code{lgb.Dataset}).
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -47,5 +48,5 @@ data_file <- tempfile(fileext = ".data")
|
|||
lgb.Dataset.save(dtrain, data_file)
|
||||
dtrain <- lgb.Dataset(data_file)
|
||||
lgb.Dataset.construct(dtrain)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,10 @@ lgb.Dataset.construct(dataset)
|
|||
Construct Dataset explicitly
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
lgb.Dataset.construct(dtrain)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@ constructed dataset
|
|||
Construct validation data according to training data
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
data(agaricus.test, package = "lightgbm")
|
||||
test <- agaricus.test
|
||||
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ Please note that \code{init_score} is not saved in binary file.
|
|||
If you need it, please set it again after loading Dataset.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
lgb.Dataset.save(dtrain, tempfile(fileext = ".bin"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Set the categorical features of an \code{lgb.Dataset} object. Use this function
|
|||
to tell LightGBM which features should be treated as categorical.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -28,5 +29,5 @@ data_file <- tempfile(fileext = ".data")
|
|||
lgb.Dataset.save(dtrain, data_file)
|
||||
dtrain <- lgb.Dataset(data_file)
|
||||
lgb.Dataset.set.categorical(dtrain, 1L:2L)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ passed dataset
|
|||
If you want to use validation data, you should set reference to training data
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package ="lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -25,5 +26,5 @@ data(agaricus.test, package = "lightgbm")
|
|||
test <- agaricus.test
|
||||
dtest <- lgb.Dataset(test$data, test = train$label)
|
||||
lgb.Dataset.set.reference(dtest, dtrain)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ Attempts to prepare a clean dataset to prepare to put in a \code{lgb.Dataset}.
|
|||
NOTE: In previous releases of LightGBM, this function was called \code{lgb.prepare}.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(iris)
|
||||
|
||||
str(iris)
|
||||
|
@ -30,11 +31,10 @@ str(iris)
|
|||
# Convert all factors/chars to integer
|
||||
str(lgb.convert(data = iris))
|
||||
|
||||
\dontrun{
|
||||
# When lightgbm package is installed, and you do not want to load it
|
||||
# You can still use the function!
|
||||
lgb.unloader()
|
||||
str(lightgbm::lgb.convert(data = iris))
|
||||
str(lgb.convert(data = iris))
|
||||
# 'data.frame': 150 obs. of 5 variables:
|
||||
# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
|
||||
# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
|
||||
|
@ -42,5 +42,4 @@ str(lightgbm::lgb.convert(data = iris))
|
|||
# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
|
||||
# $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ Attempts to prepare a clean dataset to prepare to put in a \code{lgb.Dataset}.
|
|||
NOTE: In previous releases of LightGBM, this function was called \code{lgb.prepare_rules2}.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(iris)
|
||||
|
||||
str(iris)
|
||||
|
@ -60,5 +61,5 @@ personal_rules <- list(
|
|||
)
|
||||
newest_iris <- lgb.convert_with_rules(data = iris, rules = personal_rules)
|
||||
str(newest_iris$data) # SUCCESS!
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ a trained model \code{lgb.CVBooster}.
|
|||
Cross validation logic used by LightGBM
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -113,3 +114,4 @@ model <- lgb.cv(
|
|||
, learning_rate = 1.0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ json format of model
|
|||
Dump LightGBM model to json
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
library(lightgbm)
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
|
|
@ -32,6 +32,7 @@ Given a \code{lgb.Booster}, return evaluation results for a
|
|||
particular metric on a particular dataset.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
# train a regression model
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
@ -59,3 +60,4 @@ print(names(model$record_evals[["test"]]))
|
|||
# Get L2 values for "test" dataset
|
||||
lgb.get.eval.result(model, "test", "l2")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ For a tree model, a \code{data.table} with the following columns:
|
|||
Creates a \code{data.table} of feature importances in a model.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -43,5 +44,5 @@ model <- lgb.train(
|
|||
|
||||
tree_imp1 <- lgb.importance(model, percentage = TRUE)
|
||||
tree_imp2 <- lgb.importance(model, percentage = FALSE)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ For regression, binary classification and lambdarank model, a \code{list} of \co
|
|||
Computes feature contribution components of rawscore prediction.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
Logit <- function(x) log(x / (1.0 - x))
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
@ -51,5 +52,5 @@ model <- lgb.train(
|
|||
)
|
||||
|
||||
tree_interpretation <- lgb.interprete(model, test$data, 1L:5L)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ Load LightGBM takes in either a file path or model string.
|
|||
If both are provided, Load will default to loading from file
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
|
|
@ -39,7 +39,7 @@ The columns of the \code{data.table} are:
|
|||
Parse a LightGBM model json dump into a \code{data.table} structure.
|
||||
}
|
||||
\examples{
|
||||
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -55,5 +55,5 @@ params <- list(
|
|||
model <- lgb.train(params, dtrain, 10L)
|
||||
|
||||
tree_dt <- lgb.model.dt.tree(model)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ The graph represents each feature as a horizontal bar of length proportional to
|
|||
Features are shown ranked in a decreasing importance order.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -57,3 +58,4 @@ model <- lgb.train(
|
|||
tree_imp <- lgb.importance(model, percentage = TRUE)
|
||||
lgb.plot.importance(tree_imp, top_n = 5L, measure = "Gain")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ The graph represents each feature as a horizontal bar of length proportional to
|
|||
contribution of a feature. Features are shown ranked in a decreasing contribution order.
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
Logit <- function(x) {
|
||||
log(x / (1.0 - x))
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ lgb.Booster
|
|||
Save LightGBM model
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
library(lightgbm)
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
|
|
@ -83,6 +83,7 @@ a trained booster model \code{lgb.Booster}.
|
|||
Logic to train with LightGBM
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -101,3 +102,4 @@ model <- lgb.train(
|
|||
, early_stopping_rounds = 3L
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ Attempts to unload LightGBM packages so you can remove objects cleanly without
|
|||
apparent reason and you do not want to restart R to fix the lost object.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -43,7 +44,6 @@ model <- lgb.train(
|
|||
, learning_rate = 1.0
|
||||
)
|
||||
|
||||
\dontrun{
|
||||
lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
|
||||
rm(model, dtrain, dtest) # Not needed if wipe = TRUE
|
||||
gc() # Not needed if wipe = TRUE
|
||||
|
@ -51,5 +51,4 @@ gc() # Not needed if wipe = TRUE
|
|||
library(lightgbm)
|
||||
# Do whatever you want again with LightGBM without object clashing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ For regression or binary classification, it returns a vector of length \code{nro
|
|||
Predicted values based on class \code{lgb.Booster}
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -70,3 +71,4 @@ model <- lgb.train(
|
|||
)
|
||||
preds <- predict(model, test$data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ readRDS.lgb.Booster(file = "", refhook = NULL)
|
|||
Attempts to load a model stored in a \code{.rds} file, using \code{\link[base]{readRDS}}
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
library(lightgbm)
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
|
|
@ -42,7 +42,7 @@ Attempts to save a model using RDS. Has an additional parameter (\code{raw})
|
|||
which decides whether to save the raw model or not.
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
library(lightgbm)
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
|
|
|
@ -38,6 +38,7 @@ The \code{name} field can be one of the following:
|
|||
}
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -48,5 +49,5 @@ lightgbm::setinfo(dtrain, "label", 1 - labels)
|
|||
|
||||
labels2 <- lightgbm::getinfo(dtrain, "label")
|
||||
stopifnot(all.equal(labels2, 1 - labels))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ Get a new \code{lgb.Dataset} containing the specified rows of
|
|||
original \code{lgb.Dataset} object
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
@ -31,5 +32,5 @@ dtrain <- lgb.Dataset(train$data, label = train$label)
|
|||
dsub <- lightgbm::slice(dtrain, seq_len(42L))
|
||||
lgb.Dataset.construct(dsub)
|
||||
labels <- lightgbm::getinfo(dsub, "label")
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ def generate_r_docs(app):
|
|||
, install = FALSE \
|
||||
, devel = FALSE \
|
||||
, examples = TRUE \
|
||||
, run_dont_run = FALSE \
|
||||
, run_dont_run = TRUE \
|
||||
, seed = 42L \
|
||||
, preview = FALSE \
|
||||
, new_process = TRUE \
|
||||
|
|
Загрузка…
Ссылка в новой задаче