Unverified Commit 18161674 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] [docs] Simplified examples to cut example run time (fixes #2988) (#2989)

* [R-package] [docs] Simplified examles to cut example run time (fixes #2988)

* updated learning rates
parent 151bf070
...@@ -45,7 +45,8 @@ If early stopping occurs, the model will have 'best_iter' field.} ...@@ -45,7 +45,8 @@ If early stopping occurs, the model will have 'best_iter' field.}
\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model} \item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
\item{callbacks}{List of callback functions that are applied at each iteration.} \item{callbacks}{list of callback functions
List of callback functions that are applied at each iteration.}
\item{...}{Additional arguments passed to \code{\link{lgb.train}}. For example \item{...}{Additional arguments passed to \code{\link{lgb.train}}. For example
\itemize{ \itemize{
......
...@@ -52,7 +52,6 @@ For regression or binary classification, it returns a vector of length \code{nro ...@@ -52,7 +52,6 @@ For regression or binary classification, it returns a vector of length \code{nro
Predicted values based on class \code{lgb.Booster} Predicted values based on class \code{lgb.Booster}
} }
\examples{ \examples{
library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
...@@ -64,11 +63,10 @@ valids <- list(test = dtest) ...@@ -64,11 +63,10 @@ valids <- list(test = dtest)
model <- lgb.train( model <- lgb.train(
params = params params = params
, data = dtrain , data = dtrain
, nrounds = 10L , nrounds = 5L
, valids = valids , valids = valids
, min_data = 1L , min_data = 1L
, learning_rate = 1.0 , learning_rate = 1.0
, early_stopping_rounds = 5L
) )
preds <- predict(model, test$data) preds <- predict(model, test$data)
} }
...@@ -18,6 +18,7 @@ readRDS.lgb.Booster(file = "", refhook = NULL) ...@@ -18,6 +18,7 @@ readRDS.lgb.Booster(file = "", refhook = NULL)
Attempts to load a model stored in a \code{.rds} file, using \code{\link[base]{readRDS}} Attempts to load a model stored in a \code{.rds} file, using \code{\link[base]{readRDS}}
} }
\examples{ \examples{
\donttest{
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
...@@ -38,5 +39,5 @@ model <- lgb.train( ...@@ -38,5 +39,5 @@ model <- lgb.train(
) )
saveRDS.lgb.Booster(model, "model.rds") saveRDS.lgb.Booster(model, "model.rds")
new_model <- readRDS.lgb.Booster("model.rds") new_model <- readRDS.lgb.Booster("model.rds")
}
} }
...@@ -42,6 +42,7 @@ Attempts to save a model using RDS. Has an additional parameter (\code{raw}) ...@@ -42,6 +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. which decides whether to save the raw model or not.
} }
\examples{ \examples{
\donttest{
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
...@@ -62,3 +63,4 @@ model <- lgb.train( ...@@ -62,3 +63,4 @@ model <- lgb.train(
) )
saveRDS.lgb.Booster(model, "model.rds") saveRDS.lgb.Booster(model, "model.rds")
} }
}
...@@ -38,7 +38,6 @@ The \code{name} field can be one of the following: ...@@ -38,7 +38,6 @@ The \code{name} field can be one of the following:
} }
} }
\examples{ \examples{
library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -24,7 +24,6 @@ Get a new \code{lgb.Dataset} containing the specified rows of ...@@ -24,7 +24,6 @@ Get a new \code{lgb.Dataset} containing the specified rows of
original \code{lgb.Dataset} object original \code{lgb.Dataset} object
} }
\examples{ \examples{
library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment