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
6be7aa7a
Commit
6be7aa7a
authored
Aug 20, 2017
by
Mikhail Korobov
Committed by
Guolin Ke
Aug 20, 2017
Browse files
TST check that single-leaf trees don't cause segfaults (#852)
parent
cc83cd67
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
tests/python_package_test/test_sklearn.py
tests/python_package_test/test_sklearn.py
+8
-1
No files found.
tests/python_package_test/test_sklearn.py
View file @
6be7aa7a
...
...
@@ -8,7 +8,7 @@ import lightgbm as lgb
import
numpy
as
np
from
sklearn.base
import
clone
from
sklearn.datasets
import
(
load_boston
,
load_breast_cancer
,
load_digits
,
load_svmlight_file
)
load_iris
,
load_svmlight_file
)
from
sklearn.externals
import
joblib
from
sklearn.metrics
import
log_loss
,
mean_squared_error
from
sklearn.model_selection
import
GridSearchCV
,
train_test_split
...
...
@@ -151,3 +151,10 @@ class TestSklearn(unittest.TestCase):
self
.
assertEqual
(
len
(
pred_origin
),
len
(
pred_pickle
))
for
preds
in
zip
(
pred_origin
,
pred_pickle
):
self
.
assertAlmostEqual
(
*
preds
,
places
=
5
)
def
test_feature_importances_single_leaf
(
self
):
clf
=
lgb
.
LGBMClassifier
(
n_estimators
=
100
)
data
=
load_iris
()
clf
.
fit
(
data
.
data
,
data
.
target
)
importances
=
clf
.
feature_importances_
self
.
assertEqual
(
len
(
importances
),
4
)
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