зеркало из https://github.com/microsoft/LightGBM.git
[R-package] fix warnings in examples (#4568)
* [R-package] fix warnings in examples * fix silently-ignored parameter
This commit is contained in:
Родитель
ee5636f16b
Коммит
b4213e96cb
|
@ -743,20 +743,23 @@ Booster <- R6::R6Class(
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' preds <- predict(model, test$data)
|
||||
#'
|
||||
#' # pass other prediction parameters
|
||||
#' predict(
|
||||
#' preds <- predict(
|
||||
#' model,
|
||||
#' test$data,
|
||||
#' params = list(
|
||||
|
@ -824,15 +827,18 @@ predict.lgb.Booster <- function(object,
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 3L
|
||||
#' )
|
||||
#' model_file <- tempfile(fileext = ".txt")
|
||||
|
@ -885,15 +891,18 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 10L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 5L
|
||||
#' )
|
||||
#' lgb.save(model, tempfile(fileext = ".txt"))
|
||||
|
@ -936,15 +945,18 @@ lgb.save <- function(booster, filename, num_iteration = NULL) {
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 10L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 5L
|
||||
#' )
|
||||
#' json_model <- lgb.dump(model)
|
||||
|
@ -983,15 +995,18 @@ lgb.dump <- function(booster, num_iteration = NULL) {
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#'
|
||||
#' # Examine valid data_name values
|
||||
|
|
|
@ -1145,12 +1145,15 @@ lgb.Dataset.set.categorical <- function(dataset, categorical_feature) {
|
|||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # create training Dataset
|
||||
#' data(agaricus.train, package ="lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
#'
|
||||
#' # create a validation Dataset, using dtrain as a reference
|
||||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset(test$data, test = train$label)
|
||||
#' dtest <- lgb.Dataset(test$data, label = test$label)
|
||||
#' lgb.Dataset.set.reference(dtest, dtrain)
|
||||
#' }
|
||||
#' @rdname lgb.Dataset.set.reference
|
||||
|
|
|
@ -63,14 +63,17 @@ CVBooster <- R6::R6Class(
|
|||
#' data(agaricus.train, package = "lightgbm")
|
||||
#' train <- agaricus.train
|
||||
#' dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' model <- lgb.cv(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , nfold = 3L
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' }
|
||||
#' @importFrom data.table data.table setorderv
|
||||
|
|
|
@ -36,15 +36,18 @@
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 3L
|
||||
#' )
|
||||
#' }
|
||||
|
|
|
@ -21,15 +21,18 @@
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 5L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#'
|
||||
#' lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
|
||||
|
|
|
@ -15,15 +15,18 @@
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 10L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 5L
|
||||
#' )
|
||||
#' model_file <- tempfile(fileext = ".rds")
|
||||
|
|
|
@ -26,15 +26,18 @@
|
|||
#' data(agaricus.test, package = "lightgbm")
|
||||
#' test <- agaricus.test
|
||||
#' dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
|
||||
#' params <- list(objective = "regression", metric = "l2")
|
||||
#' params <- list(
|
||||
#' objective = "regression"
|
||||
#' , metric = "l2"
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' )
|
||||
#' valids <- list(test = dtest)
|
||||
#' model <- lgb.train(
|
||||
#' params = params
|
||||
#' , data = dtrain
|
||||
#' , nrounds = 10L
|
||||
#' , valids = valids
|
||||
#' , min_data = 1L
|
||||
#' , learning_rate = 1.0
|
||||
#' , early_stopping_rounds = 5L
|
||||
#' )
|
||||
#' model_file <- tempfile(fileext = ".rds")
|
||||
|
|
|
@ -19,12 +19,15 @@ If you want to use validation data, you should set reference to training data
|
|||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
# create training Dataset
|
||||
data(agaricus.train, package ="lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
|
||||
# create a validation Dataset, using dtrain as a reference
|
||||
data(agaricus.test, package = "lightgbm")
|
||||
test <- agaricus.test
|
||||
dtest <- lgb.Dataset(test$data, test = train$label)
|
||||
dtest <- lgb.Dataset(test$data, label = test$label)
|
||||
lgb.Dataset.set.reference(dtest, dtrain)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,14 +159,17 @@ Cross validation logic used by LightGBM
|
|||
data(agaricus.train, package = "lightgbm")
|
||||
train <- agaricus.train
|
||||
dtrain <- lgb.Dataset(train$data, label = train$label)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
model <- lgb.cv(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, nfold = 3L
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 10L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 5L
|
||||
)
|
||||
json_model <- lgb.dump(model)
|
||||
|
|
|
@ -40,15 +40,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
|
||||
# Examine valid data_name values
|
||||
|
|
|
@ -26,15 +26,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 3L
|
||||
)
|
||||
model_file <- tempfile(fileext = ".txt")
|
||||
|
|
|
@ -28,15 +28,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 10L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 5L
|
||||
)
|
||||
lgb.save(model, tempfile(fileext = ".txt"))
|
||||
|
|
|
@ -144,15 +144,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 3L
|
||||
)
|
||||
}
|
||||
|
|
|
@ -33,15 +33,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
|
||||
lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
|
||||
|
|
|
@ -74,20 +74,23 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 5L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
preds <- predict(model, test$data)
|
||||
|
||||
# pass other prediction parameters
|
||||
predict(
|
||||
preds <- predict(
|
||||
model,
|
||||
test$data,
|
||||
params = list(
|
||||
|
|
|
@ -26,15 +26,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 10L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 5L
|
||||
)
|
||||
model_file <- tempfile(fileext = ".rds")
|
||||
|
|
|
@ -50,15 +50,18 @@ 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)
|
||||
params <- list(objective = "regression", metric = "l2")
|
||||
params <- list(
|
||||
objective = "regression"
|
||||
, metric = "l2"
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
)
|
||||
valids <- list(test = dtest)
|
||||
model <- lgb.train(
|
||||
params = params
|
||||
, data = dtrain
|
||||
, nrounds = 10L
|
||||
, valids = valids
|
||||
, min_data = 1L
|
||||
, learning_rate = 1.0
|
||||
, early_stopping_rounds = 5L
|
||||
)
|
||||
model_file <- tempfile(fileext = ".rds")
|
||||
|
|
Загрузка…
Ссылка в новой задаче