lgb.get.eval.result.Rd 1.67 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
5
6
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Booster.R
\name{lgb.get.eval.result}
\alias{lgb.get.eval.result}
\title{Get record evaluation result from booster}
\usage{
7
8
9
10
11
12
13
lgb.get.eval.result(
  booster,
  data_name,
  eval_name,
  iters = NULL,
  is_err = FALSE
)
Guolin Ke's avatar
Guolin Ke committed
14
15
16
17
}
\arguments{
\item{booster}{Object of class \code{lgb.Booster}}

18
\item{data_name}{Name of the dataset to return evaluation results for.}
Guolin Ke's avatar
Guolin Ke committed
19

20
\item{eval_name}{Name of the evaluation metric to return results for.}
Guolin Ke's avatar
Guolin Ke committed
21

22
23
\item{iters}{An integer vector of iterations you want to get evaluation results for. If NULL
(the default), evaluation results for all iterations will be returned.}
Guolin Ke's avatar
Guolin Ke committed
24
25
26
27

\item{is_err}{TRUE will return evaluation error instead}
}
\value{
28
numeric vector of evaluation result
Guolin Ke's avatar
Guolin Ke committed
29
30
}
\description{
31
32
Given a \code{lgb.Booster}, return evaluation results for a
             particular metric on a particular dataset.
Guolin Ke's avatar
Guolin Ke committed
33
}
34
\examples{
35
\donttest{
36
# train a regression model
37
38
39
40
41
42
43
44
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)
45
46
47
model <- lgb.train(
  params = params
  , data = dtrain
48
  , nrounds = 5L
49
  , valids = valids
50
51
  , min_data = 1L
  , learning_rate = 1.0
52
)
53
54
55
56
57
58
59
60

# Examine valid data_name values
print(setdiff(names(model$record_evals), "start_iter"))

# Examine valid eval_name values for dataset "test"
print(names(model$record_evals[["test"]]))

# Get L2 values for "test" dataset
61
62
lgb.get.eval.result(model, "test", "l2")
}
63
}