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
69798c3e
"...git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "15853a7a02621347aa74bdacb97bbbdc80b25cab"
Unverified
Commit
69798c3e
authored
Jan 04, 2021
by
Nikita Titov
Committed by
GitHub
Jan 04, 2021
Browse files
[python][tests] small Python tests cleanup (#3715)
parent
d1014ea6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
22 deletions
+15
-22
.gitignore
.gitignore
+1
-1
tests/python_package_test/test_basic.py
tests/python_package_test/test_basic.py
+2
-2
tests/python_package_test/test_engine.py
tests/python_package_test/test_engine.py
+12
-19
No files found.
.gitignore
View file @
69798c3e
...
...
@@ -423,7 +423,7 @@ lightgbm.Rcheck/
miktex*.zip
*.def
# Files created by R examples and tests
# Files created by R
and Python
examples and tests
**/lgb-Dataset.data
**/lgb.Dataset.data
**/model.txt
...
...
tests/python_package_test/test_basic.py
View file @
69798c3e
...
...
@@ -126,8 +126,8 @@ class TestBasic(unittest.TestCase):
est_2
=
lgb
.
train
(
params
,
train_data_2
,
num_boost_round
=
10
)
pred_2
=
est_2
.
predict
(
X_train
)
np
.
testing
.
assert_allclose
(
pred_1
,
pred_2
)
est_2
.
save_model
(
'
temp_
model.txt'
)
est_3
=
lgb
.
Booster
(
model_file
=
'
temp_
model.txt'
)
est_2
.
save_model
(
'model.txt'
)
est_3
=
lgb
.
Booster
(
model_file
=
'model.txt'
)
pred_3
=
est_3
.
predict
(
X_train
)
np
.
testing
.
assert_allclose
(
pred_2
,
pred_3
)
...
...
tests/python_package_test/test_engine.py
View file @
69798c3e
...
...
@@ -2612,7 +2612,8 @@ class TestEngine(unittest.TestCase):
def
test_reset_params_works_with_metric_num_class_and_boosting
(
self
):
X
,
y
=
load_breast_cancer
(
return_X_y
=
True
)
params
=
{
dataset_params
=
{
"max_bin"
:
150
}
booster_params
=
{
'objective'
:
'multiclass'
,
'max_depth'
:
4
,
'bagging_fraction'
:
0.8
,
...
...
@@ -2620,26 +2621,18 @@ class TestEngine(unittest.TestCase):
'boosting'
:
'gbdt'
,
'num_class'
:
5
}
dtrain
=
lgb
.
Dataset
(
X
,
y
,
params
=
{
"max_bin"
:
150
})
dtrain
=
lgb
.
Dataset
(
X
,
y
,
params
=
dataset_params
)
bst
=
lgb
.
Booster
(
params
=
params
,
params
=
booster_
params
,
train_set
=
dtrain
)
expected_params
=
{
'objective'
:
'multiclass'
,
'max_depth'
:
4
,
'bagging_fraction'
:
0.8
,
'metric'
:
[
'multi_logloss'
,
'multi_error'
],
'boosting'
:
'gbdt'
,
'num_class'
:
5
,
'max_bin'
:
150
}
assert
bst
.
params
==
expected_params
params
[
'bagging_fraction'
]
=
0.9
ret_bst
=
bst
.
reset_parameter
(
params
)
expected_params
=
dict
(
dataset_params
,
**
booster_params
)
self
.
assertDictEqual
(
bst
.
params
,
expected_params
)
booster_params
[
'bagging_fraction'
]
+=
0.1
new_bst
=
bst
.
reset_parameter
(
booster_params
)
expected_params
[
'bagging_fraction'
]
=
0.9
assert
bst
.
params
==
expected_params
assert
ret
_bst
.
params
==
expected_params
expected_params
=
dict
(
dataset_params
,
**
booster_params
)
self
.
assert
DictEqual
(
bst
.
params
,
expected_params
)
self
.
assert
DictEqual
(
new
_bst
.
params
,
expected_params
)
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