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
05d89a1a
"include/git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "b752170ba950890dd7e211fdecedef4d8deffb8b"
Unverified
Commit
05d89a1a
authored
May 11, 2020
by
James Lamb
Committed by
GitHub
May 10, 2020
Browse files
[R-package] added tests on LGBM_BoosterResetTrainingData_R (#3020)
parent
ad7f2851
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+63
-0
No files found.
R-package/tests/testthat/test_lgb.Booster.R
View file @
05d89a1a
...
@@ -311,3 +311,66 @@ test_that("Booster$rollback_one_iter() should work as expected", {
...
@@ -311,3 +311,66 @@ test_that("Booster$rollback_one_iter() should work as expected", {
logloss
<-
bst
$
eval_train
()[[
1L
]][[
"value"
]]
logloss
<-
bst
$
eval_train
()[[
1L
]][[
"value"
]]
expect_equal
(
logloss
,
0.027915146
)
expect_equal
(
logloss
,
0.027915146
)
})
})
test_that
(
"Booster$update() passing a train_set works as expected"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
nrounds
<-
2L
# train with 2 rounds and then update
bst
<-
lightgbm
(
data
=
as.matrix
(
agaricus.train
$
data
)
,
label
=
agaricus.train
$
label
,
num_leaves
=
4L
,
learning_rate
=
1.0
,
nrounds
=
nrounds
,
objective
=
"binary"
)
expect_true
(
lgb.is.Booster
(
bst
))
expect_equal
(
bst
$
current_iter
(),
nrounds
)
bst
$
update
(
train_set
=
Dataset
$
new
(
data
=
agaricus.train
$
data
,
label
=
agaricus.train
$
label
)
)
expect_true
(
lgb.is.Booster
(
bst
))
expect_equal
(
bst
$
current_iter
(),
nrounds
+
1L
)
# train with 3 rounds directlry
bst2
<-
lightgbm
(
data
=
as.matrix
(
agaricus.train
$
data
)
,
label
=
agaricus.train
$
label
,
num_leaves
=
4L
,
learning_rate
=
1.0
,
nrounds
=
nrounds
+
1L
,
objective
=
"binary"
)
expect_true
(
lgb.is.Booster
(
bst2
))
expect_equal
(
bst2
$
current_iter
(),
nrounds
+
1L
)
# model with 2 rounds + 1 update should be identical to 3 rounds
expect_equal
(
bst2
$
eval_train
()[[
1L
]][[
"value"
]],
0.04806585
)
expect_equal
(
bst
$
eval_train
()[[
1L
]][[
"value"
]],
bst2
$
eval_train
()[[
1L
]][[
"value"
]])
})
test_that
(
"Booster$update() throws an informative error if you provide a non-Dataset to update()"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
nrounds
<-
2L
# train with 2 rounds and then update
bst
<-
lightgbm
(
data
=
as.matrix
(
agaricus.train
$
data
)
,
label
=
agaricus.train
$
label
,
num_leaves
=
4L
,
learning_rate
=
1.0
,
nrounds
=
nrounds
,
objective
=
"binary"
)
expect_error
({
bst
$
update
(
train_set
=
data.frame
(
x
=
rnorm
(
10L
))
)
},
regexp
=
"lgb.Booster.update: Only can use lgb.Dataset"
,
fixed
=
TRUE
)
})
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