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
8c6933ec
Commit
8c6933ec
authored
Dec 30, 2016
by
Tsukasa OMOTO
Committed by
Guolin Ke
Dec 30, 2016
Browse files
fix creating valid_sets (#148)
* fix creating valid_sets * support both list and dict * update Python-API.md
parent
7bba0bfc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
docs/Python-API.md
docs/Python-API.md
+3
-3
python-package/lightgbm/sklearn.py
python-package/lightgbm/sklearn.py
+15
-3
No files found.
docs/Python-API.md
View file @
8c6933ec
...
@@ -721,11 +721,11 @@ The methods of each Class is in alphabetical order.
...
@@ -721,11 +721,11 @@ The methods of each Class is in alphabetical order.
group data of training data
group data of training data
eval_set : list, optional
eval_set : list, optional
A list of (X, y) tuple pairs to use as a validation set for early-stopping
A list of (X, y) tuple pairs to use as a validation set for early-stopping
eval_sample_weight : List of array
eval_sample_weight : List
or Dict
of array
weight of eval data
weight of eval data
eval_init_score : List of array
eval_init_score : List
or Dict
of array
init score of eval data
init score of eval data
eval_group : List of array
eval_group : List
or Dict
of array
group data of eval data
group data of eval data
eval_metric : str, list of str, callable, optional
eval_metric : str, list of str, callable, optional
If a str, should be a built-in evaluation metric to use.
If a str, should be a built-in evaluation metric to use.
...
...
python-package/lightgbm/sklearn.py
View file @
8c6933ec
...
@@ -375,9 +375,21 @@ class LGBMModel(LGBMModelBase):
...
@@ -375,9 +375,21 @@ class LGBMModel(LGBMModelBase):
if
valid_data
[
0
]
is
X
and
valid_data
[
1
]
is
y
:
if
valid_data
[
0
]
is
X
and
valid_data
[
1
]
is
y
:
valid_set
=
train_set
valid_set
=
train_set
else
:
else
:
valid_weight
=
None
if
eval_sample_weight
is
None
else
eval_sample_weight
.
get
(
i
,
None
)
def
get_meta_data
(
collection
,
i
):
valid_init_score
=
None
if
eval_init_score
is
None
else
eval_init_score
.
get
(
i
,
None
)
if
collection
is
None
:
valid_group
=
None
if
eval_group
is
None
else
eval_group
.
get
(
i
,
None
)
return
None
elif
isinstance
(
collection
,
list
):
if
len
(
collection
)
>
i
:
return
collection
[
i
]
else
:
return
None
elif
isinstance
(
collection
,
dict
):
return
collection
.
get
(
i
,
None
)
else
:
raise
TypeError
(
'eval_sample_weight, eval_init_score, and eval_group should be dict or list'
)
valid_weight
=
get_meta_data
(
eval_sample_weight
,
i
)
valid_init_score
=
get_meta_data
(
eval_init_score
,
i
)
valid_group
=
get_meta_data
(
eval_group
,
i
)
valid_set
=
_construct_dataset
(
valid_data
[
0
],
valid_data
[
1
],
valid_weight
,
valid_init_score
,
valid_group
,
params
)
valid_set
=
_construct_dataset
(
valid_data
[
0
],
valid_data
[
1
],
valid_weight
,
valid_init_score
,
valid_group
,
params
)
valid_sets
.
append
(
valid_set
)
valid_sets
.
append
(
valid_set
)
...
...
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