readRDS.lgb.Booster.Rd 1.11 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/readRDS.lgb.Booster.R
\name{readRDS.lgb.Booster}
\alias{readRDS.lgb.Booster}
Nikita Titov's avatar
Nikita Titov committed
5
\title{readRDS for \code{lgb.Booster} models}
Guolin Ke's avatar
Guolin Ke committed
6
7
8
9
10
11
12
13
14
\usage{
readRDS.lgb.Booster(file = "", refhook = NULL)
}
\arguments{
\item{file}{a connection or the name of the file where the R object is saved to or read from.}

\item{refhook}{a hook function for handling reference objects.}
}
\value{
Nikita Titov's avatar
Nikita Titov committed
15
\code{lgb.Booster}.
Guolin Ke's avatar
Guolin Ke committed
16
17
}
\description{
James Lamb's avatar
James Lamb committed
18
Attempts to load a model using RDS.
Guolin Ke's avatar
Guolin Ke committed
19
20
}
\examples{
21
22
23
24
25
26
27
28
29
library(lightgbm)
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)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
30
31
32
33
34
35
36
37
38
model <- lgb.train(
  params = params
  , data = dtrain
  , nrounds = 10
  , valids = valids
  , min_data = 1
  , learning_rate = 1
  , early_stopping_rounds = 5
)
39
40
saveRDS.lgb.Booster(model, "model.rds")
new_model <- readRDS.lgb.Booster("model.rds")
Guolin Ke's avatar
Guolin Ke committed
41
42

}