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
795ff82f
Commit
795ff82f
authored
Jan 03, 2017
by
Guolin Ke
Browse files
[package] fix some type check
parent
6b73b4ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+9
-5
No files found.
python-package/lightgbm/basic.py
View file @
795ff82f
...
...
@@ -852,7 +852,7 @@ class _InnerDataset(object):
Init score for booster
"""
if
score
is
not
None
:
score
=
list_to_1d_numpy
(
score
,
name
=
'init
score'
)
score
=
list_to_1d_numpy
(
score
,
name
=
'init
_
score'
)
self
.
set_field
(
'init_score'
,
score
)
def
set_group
(
self
,
group
):
...
...
@@ -986,7 +986,7 @@ class Dataset(object):
Parameters
----------
data : string/numpy array/scipy.sparse
Data source of
_Inner
Dataset.
Data source of Dataset.
When data type is string, it represents the path of txt file
label : list or numpy 1-D array, optional
Label of the training data.
...
...
@@ -1396,6 +1396,8 @@ class Booster(object):
name : String
Name of validation data
"""
if
not
isinstance
(
data
,
Dataset
):
raise
TypeError
(
'valid data should be Dataset instance, met {}'
.
format
(
type
(
train_set
).
__name__
))
if
data
.
_predictor
is
not
self
.
__init_predictor
:
raise
LightGBMError
(
"Add validation data failed, you should use same predictor for these data"
)
_safe_call
(
_LIB
.
LGBM_BoosterAddValidData
(
...
...
@@ -1447,6 +1449,8 @@ class Booster(object):
"""need reset training data"""
if
train_set
is
not
None
and
train_set
is
not
self
.
train_set
:
if
not
isinstance
(
train_set
,
Dataset
):
raise
TypeError
(
'Training data should be Dataset instance, met {}'
.
format
(
type
(
train_set
).
__name__
))
if
train_set
.
_predictor
is
not
self
.
__init_predictor
:
raise
LightGBMError
(
"Replace training data failed, you should use same predictor for these data"
)
self
.
train_set
=
train_set
...
...
@@ -1517,7 +1521,7 @@ class Booster(object):
Parameters
----------
data :
_Inner
Dataset object
data : Dataset object
name :
Name of data
feval : function
...
...
@@ -1527,8 +1531,8 @@ class Booster(object):
result: list
Evaluation result list.
"""
if
not
isinstance
(
data
,
_Inner
Dataset
):
raise
TypeError
(
"Can only eval for
_Inner
Dataset instance"
)
if
not
isinstance
(
data
,
Dataset
):
raise
TypeError
(
"Can only eval for Dataset instance"
)
data_idx
=
-
1
if
data
is
self
.
train_set
:
data_idx
=
0
...
...
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