Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
2b9175aa
Unverified
Commit
2b9175aa
authored
Apr 25, 2020
by
James Lamb
Committed by
GitHub
Apr 25, 2020
Browse files
[R-package] added tests on LGBM_BoosterRollbackOneIter_R (#3006)
parent
b05520e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+32
-0
No files found.
R-package/tests/testthat/test_lgb.Booster.R
View file @
2b9175aa
...
@@ -279,3 +279,35 @@ test_that("Creating a Booster from a Dataset with an existing predictor should w
...
@@ -279,3 +279,35 @@ test_that("Creating a Booster from a Dataset with an existing predictor should w
expect_identical
(
bst_from_ds
$
eval_train
(),
list
())
expect_identical
(
bst_from_ds
$
eval_train
(),
list
())
expect_equal
(
bst_from_ds
$
current_iter
(),
nrounds
)
expect_equal
(
bst_from_ds
$
current_iter
(),
nrounds
)
})
})
test_that
(
"Booster$rollback_one_iter() should work as expected"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
data
(
agaricus.test
,
package
=
"lightgbm"
)
train
<-
agaricus.train
test
<-
agaricus.test
nrounds
<-
5L
bst
<-
lightgbm
(
data
=
as.matrix
(
train
$
data
)
,
label
=
train
$
label
,
num_leaves
=
4L
,
learning_rate
=
1.0
,
nrounds
=
nrounds
,
objective
=
"binary"
)
expect_equal
(
bst
$
current_iter
(),
nrounds
)
expect_true
(
lgb.is.Booster
(
bst
))
logloss
<-
bst
$
eval_train
()[[
1L
]][[
"value"
]]
expect_equal
(
logloss
,
0.01904786
)
x
<-
bst
$
rollback_one_iter
()
# rollback_one_iter() should return a booster and modify the original
# booster in place
expect_true
(
lgb.is.Booster
(
x
))
expect_equal
(
bst
$
current_iter
(),
nrounds
-
1L
)
# score should now come from the model as of 4 iterations
logloss
<-
bst
$
eval_train
()[[
1L
]][[
"value"
]]
expect_equal
(
logloss
,
0.027915146
)
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment