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
dd3294d7
Unverified
Commit
dd3294d7
authored
May 22, 2022
by
James Lamb
Committed by
GitHub
May 22, 2022
Browse files
[R-package] silence more logs in unit tests (#5227)
parent
0ebbf1e4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+4
-0
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+29
-4
No files found.
R-package/tests/testthat/test_basic.R
View file @
dd3294d7
...
@@ -78,6 +78,7 @@ test_that("train and predict binary classification", {
...
@@ -78,6 +78,7 @@ test_that("train and predict binary classification", {
num_leaves
=
5L
num_leaves
=
5L
,
objective
=
"binary"
,
objective
=
"binary"
,
metric
=
"binary_error"
,
metric
=
"binary_error"
,
verbose
=
VERBOSITY
)
)
,
nrounds
=
nrounds
,
nrounds
=
nrounds
,
valids
=
list
(
,
valids
=
list
(
...
@@ -118,6 +119,7 @@ test_that("train and predict softmax", {
...
@@ -118,6 +119,7 @@ test_that("train and predict softmax", {
,
objective
=
"multiclass"
,
objective
=
"multiclass"
,
metric
=
"multi_error"
,
metric
=
"multi_error"
,
num_class
=
3L
,
num_class
=
3L
,
verbose
=
VERBOSITY
)
)
,
nrounds
=
20L
,
nrounds
=
20L
,
valids
=
list
(
,
valids
=
list
(
...
@@ -147,6 +149,7 @@ test_that("use of multiple eval metrics works", {
...
@@ -147,6 +149,7 @@ test_that("use of multiple eval metrics works", {
,
learning_rate
=
1.0
,
learning_rate
=
1.0
,
objective
=
"binary"
,
objective
=
"binary"
,
metric
=
metrics
,
metric
=
metrics
,
verbose
=
VERBOSITY
)
)
,
nrounds
=
10L
,
nrounds
=
10L
,
valids
=
list
(
,
valids
=
list
(
...
@@ -298,6 +301,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
...
@@ -298,6 +301,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
"binary_error"
"binary_error"
,
"auc"
,
"auc"
)
)
,
verbose
=
VERBOSITY
)
)
,
nrounds
=
nrounds
,
nrounds
=
nrounds
,
valids
=
list
(
,
valids
=
list
(
...
...
R-package/tests/testthat/test_dataset.R
View file @
dd3294d7
...
@@ -12,7 +12,13 @@ test_label <- agaricus.test$label[1L:100L]
...
@@ -12,7 +12,13 @@ test_label <- agaricus.test$label[1L:100L]
test_that
(
"lgb.Dataset: basic construction, saving, loading"
,
{
test_that
(
"lgb.Dataset: basic construction, saving, loading"
,
{
# from sparse matrix
# from sparse matrix
dtest1
<-
lgb.Dataset
(
test_data
,
label
=
test_label
)
dtest1
<-
lgb.Dataset
(
test_data
,
label
=
test_label
,
params
=
list
(
verbose
=
VERBOSITY
)
)
# from dense matrix
# from dense matrix
dtest2
<-
lgb.Dataset
(
as.matrix
(
test_data
),
label
=
test_label
)
dtest2
<-
lgb.Dataset
(
as.matrix
(
test_data
),
label
=
test_label
)
expect_equal
(
get_field
(
dtest1
,
"label"
),
get_field
(
dtest2
,
"label"
))
expect_equal
(
get_field
(
dtest1
,
"label"
),
get_field
(
dtest2
,
"label"
))
...
@@ -21,7 +27,12 @@ test_that("lgb.Dataset: basic construction, saving, loading", {
...
@@ -21,7 +27,12 @@ test_that("lgb.Dataset: basic construction, saving, loading", {
tmp_file
<-
tempfile
(
"lgb.Dataset_"
)
tmp_file
<-
tempfile
(
"lgb.Dataset_"
)
lgb.Dataset.save
(
dtest1
,
tmp_file
)
lgb.Dataset.save
(
dtest1
,
tmp_file
)
# read from a local file
# read from a local file
dtest3
<-
lgb.Dataset
(
tmp_file
)
dtest3
<-
lgb.Dataset
(
tmp_file
,
params
=
list
(
verbose
=
VERBOSITY
)
)
lgb.Dataset.construct
(
dtest3
)
lgb.Dataset.construct
(
dtest3
)
unlink
(
tmp_file
)
unlink
(
tmp_file
)
expect_equal
(
get_field
(
dtest1
,
"label"
),
get_field
(
dtest3
,
"label"
))
expect_equal
(
get_field
(
dtest1
,
"label"
),
get_field
(
dtest3
,
"label"
))
...
@@ -358,6 +369,9 @@ test_that("lgb.Dataset: should be able to run lgb.train() immediately after usin
...
@@ -358,6 +369,9 @@ test_that("lgb.Dataset: should be able to run lgb.train() immediately after usin
dtest
<-
lgb.Dataset
(
dtest
<-
lgb.Dataset
(
data
=
test_data
data
=
test_data
,
label
=
test_label
,
label
=
test_label
,
params
=
list
(
verbose
=
VERBOSITY
)
)
)
tmp_file
<-
tempfile
(
pattern
=
"lgb.Dataset_"
)
tmp_file
<-
tempfile
(
pattern
=
"lgb.Dataset_"
)
lgb.Dataset.save
(
lgb.Dataset.save
(
...
@@ -389,6 +403,9 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
...
@@ -389,6 +403,9 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
dtest
<-
lgb.Dataset
(
dtest
<-
lgb.Dataset
(
data
=
test_data
data
=
test_data
,
label
=
test_label
,
label
=
test_label
,
params
=
list
(
verbosity
=
VERBOSITY
)
)
)
tmp_file
<-
tempfile
(
pattern
=
"lgb.Dataset_"
)
tmp_file
<-
tempfile
(
pattern
=
"lgb.Dataset_"
)
lgb.Dataset.save
(
lgb.Dataset.save
(
...
@@ -404,6 +421,8 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
...
@@ -404,6 +421,8 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
,
metric
=
"binary_logloss"
,
metric
=
"binary_logloss"
,
num_leaves
=
5L
,
num_leaves
=
5L
,
learning_rate
=
1.0
,
learning_rate
=
1.0
,
num_iterations
=
5L
,
verbosity
=
VERBOSITY
)
)
# should be able to train right away
# should be able to train right away
...
@@ -446,7 +465,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
...
@@ -446,7 +465,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
dtrain
<-
lgb.Dataset
(
dtrain
<-
lgb.Dataset
(
data
=
train_file
data
=
train_file
,
params
=
list
(
header
=
TRUE
)
,
params
=
list
(
header
=
TRUE
,
verbosity
=
VERBOSITY
)
)
)
dtrain
$
construct
()
dtrain
$
construct
()
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"x1"
,
"x2"
))
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"x1"
,
"x2"
))
...
@@ -467,7 +489,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
...
@@ -467,7 +489,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
dtrain
<-
lgb.Dataset
(
dtrain
<-
lgb.Dataset
(
data
=
train_file
data
=
train_file
,
params
=
list
(
header
=
FALSE
)
,
params
=
list
(
header
=
FALSE
,
verbosity
=
VERBOSITY
)
)
)
dtrain
$
construct
()
dtrain
$
construct
()
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"Column_0"
,
"Column_1"
))
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"Column_0"
,
"Column_1"
))
...
...
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