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
3d620bfc
Unverified
Commit
3d620bfc
authored
Apr 03, 2022
by
James Lamb
Committed by
GitHub
Apr 03, 2022
Browse files
[R-package] ensure boosting happens in tests on small datasets (#5121)
parent
78207462
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
7 deletions
+34
-7
R-package/tests/testthat/test_Predictor.R
R-package/tests/testthat/test_Predictor.R
+9
-1
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+7
-2
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+18
-4
No files found.
R-package/tests/testthat/test_Predictor.R
View file @
3d620bfc
...
...
@@ -116,12 +116,20 @@ test_that("predictions for regression and binary classification are returned as
data
(
mtcars
)
X
<-
as.matrix
(
mtcars
[,
-1L
])
y
<-
as.numeric
(
mtcars
[,
1L
])
dtrain
<-
lgb.Dataset
(
X
,
label
=
y
,
params
=
list
(
max_bins
=
5L
))
dtrain
<-
lgb.Dataset
(
X
,
label
=
y
,
params
=
list
(
max_bins
=
5L
,
min_data_in_bin
=
1L
)
)
model
<-
lgb.train
(
data
=
dtrain
,
obj
=
"regression"
,
nrounds
=
5L
,
verbose
=
VERBOSITY
,
params
=
list
(
min_data_in_leaf
=
1L
)
)
pred
<-
predict
(
model
,
X
)
expect_true
(
is.vector
(
pred
))
...
...
R-package/tests/testthat/test_basic.R
View file @
3d620bfc
...
...
@@ -1718,7 +1718,8 @@ test_that("lgb.train() works with integer, double, and numeric data", {
,
label
=
y
,
params
=
list
(
objective
=
"regression"
,
min_data
=
1L
,
min_data_in_bin
=
1L
,
min_data_in_leaf
=
1L
,
learning_rate
=
0.01
,
seed
=
708L
)
...
...
@@ -2984,7 +2985,11 @@ test_that("lightgbm() accepts 'weight' and 'weights'", {
,
weights
=
w
,
obj
=
"regression"
,
nrounds
=
5L
,
verbose
=
-1L
,
verbose
=
VERBOSITY
,
params
=
list
(
min_data_in_bin
=
1L
,
min_data_in_leaf
=
1L
)
)
expect_equal
(
model
$
.__enclos_env__
$
private
$
train_set
$
get_field
(
"weight"
),
w
)
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
3d620bfc
...
...
@@ -1273,10 +1273,17 @@ test_that("Booster's print, show, and summary work correctly", {
data
(
"mtcars"
)
model
<-
lgb.train
(
params
=
list
(
objective
=
"regression"
)
params
=
list
(
objective
=
"regression"
,
min_data_in_leaf
=
1L
)
,
data
=
lgb.Dataset
(
as.matrix
(
mtcars
[,
-1L
])
,
label
=
mtcars
$
mpg
)
,
label
=
mtcars
$
mpg
,
params
=
list
(
min_data_in_bin
=
1L
)
)
,
verbose
=
VERBOSITY
,
nrounds
=
5L
)
...
...
@@ -1332,10 +1339,17 @@ test_that("Booster's print, show, and summary work correctly", {
test_that
(
"LGBM_BoosterGetNumFeature_R returns correct outputs"
,
{
data
(
"mtcars"
)
model
<-
lgb.train
(
params
=
list
(
objective
=
"regression"
)
params
=
list
(
objective
=
"regression"
,
min_data_in_leaf
=
1L
)
,
data
=
lgb.Dataset
(
as.matrix
(
mtcars
[,
-1L
])
,
label
=
mtcars
$
mpg
)
,
label
=
mtcars
$
mpg
,
params
=
list
(
min_data_in_bin
=
1L
)
)
,
verbose
=
VERBOSITY
,
nrounds
=
5L
)
...
...
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