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
f7037fd5
Unverified
Commit
f7037fd5
authored
Mar 02, 2020
by
James Lamb
Committed by
GitHub
Mar 02, 2020
Browse files
[R-package] added test on training with sparse features (#2847)
parent
da91c613
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+31
-0
No files found.
R-package/tests/testthat/test_basic.R
View file @
f7037fd5
...
...
@@ -327,3 +327,34 @@ test_that("lgb.train() works with force_col_wise and force_row_wise", {
expect_false
(
parsed_model
$
average_output
)
}
})
test_that
(
"lgb.train() works as expected with sparse features"
,
{
set.seed
(
708L
)
num_obs
<-
70000L
trainDF
<-
data.frame
(
y
=
sample
(
c
(
0L
,
1L
),
size
=
num_obs
,
replace
=
TRUE
)
,
x
=
sample
(
c
(
1.0
:
10.0
,
rep
(
NA_real_
,
50L
)),
size
=
num_obs
,
replace
=
TRUE
)
)
dtrain
<-
lgb.Dataset
(
data
=
as.matrix
(
trainDF
[[
"x"
]],
drop
=
FALSE
)
,
label
=
trainDF
[[
"y"
]]
)
nrounds
<-
1L
bst
<-
lgb.train
(
params
=
list
(
objective
=
"binary"
,
min_data
=
1L
,
min_data_in_bin
=
1L
)
,
data
=
dtrain
,
nrounds
=
nrounds
)
expect_true
(
lgb.is.Booster
(
bst
))
expect_equal
(
bst
$
current_iter
(),
nrounds
)
parsed_model
<-
jsonlite
::
fromJSON
(
bst
$
dump_model
())
expect_equal
(
parsed_model
$
objective
,
"binary sigmoid:1"
)
expect_false
(
parsed_model
$
average_output
)
expected_error
<-
0.6931268
expect_true
(
abs
(
bst
$
eval_train
()[[
1L
]][[
"value"
]]
-
expected_error
)
<
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