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
b9dc51a6
Commit
b9dc51a6
authored
Oct 24, 2017
by
Nikita Titov
Committed by
Guolin Ke
Oct 24, 2017
Browse files
[python] fixed stratifiedkfold for non-classifying tasks (#1016)
* Update test_engine.py * Update test_engine.py
parent
66c81af2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
tests/python_package_test/test_engine.py
tests/python_package_test/test_engine.py
+4
-4
No files found.
tests/python_package_test/test_engine.py
View file @
b9dc51a6
...
...
@@ -416,22 +416,22 @@ class TestEngine(unittest.TestCase):
lgb_train
=
lgb
.
Dataset
(
X_train
,
y_train
)
# shuffle = False, override metric in params
params_with_metric
=
{
'metric'
:
'l2'
,
'verbose'
:
-
1
}
lgb
.
cv
(
params_with_metric
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
shuffle
=
False
,
lgb
.
cv
(
params_with_metric
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
stratified
=
False
,
shuffle
=
False
,
metrics
=
'l1'
,
verbose_eval
=
False
)
# shuffle = True, callbacks
lgb
.
cv
(
params
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
shuffle
=
True
,
lgb
.
cv
(
params
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
stratified
=
False
,
shuffle
=
True
,
metrics
=
'l1'
,
verbose_eval
=
False
,
callbacks
=
[
lgb
.
reset_parameter
(
learning_rate
=
lambda
i
:
0.1
-
0.001
*
i
)])
# self defined folds
tss
=
TimeSeriesSplit
(
3
)
folds
=
tss
.
split
(
X_train
)
lgb
.
cv
(
params_with_metric
,
lgb_train
,
num_boost_round
=
10
,
folds
=
folds
,
verbose_eval
=
False
)
lgb
.
cv
(
params_with_metric
,
lgb_train
,
num_boost_round
=
10
,
folds
=
folds
,
stratified
=
False
,
verbose_eval
=
False
)
# lambdarank
X_train
,
y_train
=
load_svmlight_file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'../../examples/lambdarank/rank.train'
))
q_train
=
np
.
loadtxt
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'../../examples/lambdarank/rank.train.query'
))
params_lambdarank
=
{
'objective'
:
'lambdarank'
,
'verbose'
:
-
1
}
lgb_train
=
lgb
.
Dataset
(
X_train
,
y_train
,
group
=
q_train
)
lgb
.
cv
(
params_lambdarank
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
metrics
=
'l2'
,
verbose_eval
=
False
)
lgb
.
cv
(
params_lambdarank
,
lgb_train
,
num_boost_round
=
10
,
nfold
=
3
,
stratified
=
False
,
metrics
=
'l2'
,
verbose_eval
=
False
)
def
test_feature_name
(
self
):
X
,
y
=
load_boston
(
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