lgb.get.eval.result.Rd 1.7 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
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)
43
44
45
46
47
params <- list(
  objective = "regression"
  , metric = "l2"
  , min_data = 1L
  , learning_rate = 1.0
48
  , num_threads = 2L
49
)
50
valids <- list(test = dtest)
51
52
53
model <- lgb.train(
  params = params
  , data = dtrain
54
  , nrounds = 5L
55
56
  , valids = valids
)
57
58
59
60
61
62
63
64

# 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
65
66
lgb.get.eval.result(model, "test", "l2")
}
67
}