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
0e3509cb
Unverified
Commit
0e3509cb
authored
May 16, 2020
by
James Lamb
Committed by
GitHub
May 16, 2020
Browse files
[R-package] fix warnings in tests (#3069)
parent
4d994c63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+7
-6
No files found.
R-package/tests/testthat/test_basic.R
View file @
0e3509cb
...
@@ -33,6 +33,7 @@ test_that("train and predict binary classification", {
...
@@ -33,6 +33,7 @@ test_that("train and predict binary classification", {
test_that
(
"train and predict softmax"
,
{
test_that
(
"train and predict softmax"
,
{
set.seed
(
708L
)
lb
<-
as.numeric
(
iris
$
Species
)
-
1L
lb
<-
as.numeric
(
iris
$
Species
)
-
1L
bst
<-
lightgbm
(
bst
<-
lightgbm
(
...
@@ -42,7 +43,7 @@ test_that("train and predict softmax", {
...
@@ -42,7 +43,7 @@ test_that("train and predict softmax", {
,
learning_rate
=
0.1
,
learning_rate
=
0.1
,
nrounds
=
20L
,
nrounds
=
20L
,
min_data
=
20L
,
min_data
=
20L
,
min_hess
=
20.0
,
min_hess
ian
=
20.0
,
objective
=
"multiclass"
,
objective
=
"multiclass"
,
metric
=
"multi_error"
,
metric
=
"multi_error"
,
num_class
=
3L
,
num_class
=
3L
...
@@ -50,7 +51,7 @@ test_that("train and predict softmax", {
...
@@ -50,7 +51,7 @@ test_that("train and predict softmax", {
expect_false
(
is.null
(
bst
$
record_evals
))
expect_false
(
is.null
(
bst
$
record_evals
))
record_results
<-
lgb.get.eval.result
(
bst
,
"train"
,
"multi_error"
)
record_results
<-
lgb.get.eval.result
(
bst
,
"train"
,
"multi_error"
)
expect_lt
(
min
(
record_results
),
0.0
3
)
expect_lt
(
min
(
record_results
),
0.0
5
)
pred
<-
predict
(
bst
,
as.matrix
(
iris
[,
-5L
]))
pred
<-
predict
(
bst
,
as.matrix
(
iris
[,
-5L
]))
expect_equal
(
length
(
pred
),
nrow
(
iris
)
*
3L
)
expect_equal
(
length
(
pred
),
nrow
(
iris
)
*
3L
)
...
@@ -125,11 +126,11 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
...
@@ -125,11 +126,11 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
set.seed
(
708L
)
set.seed
(
708L
)
dvalid1
<-
lgb.Dataset
(
dvalid1
<-
lgb.Dataset
(
data
=
train
$
data
data
=
train
$
data
,
label
s
=
train
$
label
,
label
=
train
$
label
)
)
dvalid2
<-
lgb.Dataset
(
dvalid2
<-
lgb.Dataset
(
data
=
train
$
data
data
=
train
$
data
,
label
s
=
train
$
label
,
label
=
train
$
label
)
)
nrounds
<-
10L
nrounds
<-
10L
bst
<-
lightgbm
(
bst
<-
lightgbm
(
...
@@ -156,8 +157,8 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
...
@@ -156,8 +157,8 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
expect_length
(
eval_results
[[
"eval"
]],
nrounds
)
expect_length
(
eval_results
[[
"eval"
]],
nrounds
)
}
}
expect_true
(
abs
(
bst
$
record_evals
[[
"train"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.02226317
)
<
TOLERANCE
)
expect_true
(
abs
(
bst
$
record_evals
[[
"train"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.02226317
)
<
TOLERANCE
)
expect_true
(
abs
(
bst
$
record_evals
[[
"valid1"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.
4825733
)
<
TOLERANCE
)
expect_true
(
abs
(
bst
$
record_evals
[[
"valid1"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.
02226317
)
<
TOLERANCE
)
expect_true
(
abs
(
bst
$
record_evals
[[
"valid2"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.
4825733
)
<
TOLERANCE
)
expect_true
(
abs
(
bst
$
record_evals
[[
"valid2"
]][[
"binary_error"
]][[
"eval"
]][[
1L
]]
-
0.
02226317
)
<
TOLERANCE
)
})
})
...
...
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