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
eb13f39a
Unverified
Commit
eb13f39a
authored
Jun 23, 2022
by
James Lamb
Committed by
GitHub
Jun 23, 2022
Browse files
[python-package] add more type hints on Booster (#5309)
[python-package] add more hints on Booster
parent
4b64b173
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+12
-12
No files found.
python-package/lightgbm/basic.py
View file @
eb13f39a
...
@@ -2781,7 +2781,7 @@ class Booster:
...
@@ -2781,7 +2781,7 @@ class Booster:
self
.
network
=
False
self
.
network
=
False
return
self
return
self
def
trees_to_dataframe
(
self
):
def
trees_to_dataframe
(
self
)
->
pd_DataFrame
:
"""Parse the fitted model and return in an easy-to-read pandas DataFrame.
"""Parse the fitted model and return in an easy-to-read pandas DataFrame.
The returned DataFrame has the following columns.
The returned DataFrame has the following columns.
...
@@ -2917,7 +2917,7 @@ class Booster:
...
@@ -2917,7 +2917,7 @@ class Booster:
return
pd_DataFrame
(
model_list
,
columns
=
model_list
[
0
].
keys
())
return
pd_DataFrame
(
model_list
,
columns
=
model_list
[
0
].
keys
())
def
set_train_data_name
(
self
,
name
)
:
def
set_train_data_name
(
self
,
name
:
str
)
->
"Booster"
:
"""Set the name to the training Dataset.
"""Set the name to the training Dataset.
Parameters
Parameters
...
@@ -2933,7 +2933,7 @@ class Booster:
...
@@ -2933,7 +2933,7 @@ class Booster:
self
.
_train_data_name
=
name
self
.
_train_data_name
=
name
return
self
return
self
def
add_valid
(
self
,
data
,
name
)
:
def
add_valid
(
self
,
data
:
Dataset
,
name
:
str
)
->
"Booster"
:
"""Add validation data.
"""Add validation data.
Parameters
Parameters
...
@@ -2963,7 +2963,7 @@ class Booster:
...
@@ -2963,7 +2963,7 @@ class Booster:
self
.
__is_predicted_cur_iter
.
append
(
False
)
self
.
__is_predicted_cur_iter
.
append
(
False
)
return
self
return
self
def
reset_parameter
(
self
,
params
)
:
def
reset_parameter
(
self
,
params
:
Dict
[
str
,
Any
])
->
"Booster"
:
"""Reset parameters of Booster.
"""Reset parameters of Booster.
Parameters
Parameters
...
@@ -3100,7 +3100,7 @@ class Booster:
...
@@ -3100,7 +3100,7 @@ class Booster:
self
.
__is_predicted_cur_iter
=
[
False
for
_
in
range
(
self
.
__num_dataset
)]
self
.
__is_predicted_cur_iter
=
[
False
for
_
in
range
(
self
.
__num_dataset
)]
return
is_finished
.
value
==
1
return
is_finished
.
value
==
1
def
rollback_one_iter
(
self
):
def
rollback_one_iter
(
self
)
->
"Booster"
:
"""Rollback one iteration.
"""Rollback one iteration.
Returns
Returns
...
@@ -3113,7 +3113,7 @@ class Booster:
...
@@ -3113,7 +3113,7 @@ class Booster:
self
.
__is_predicted_cur_iter
=
[
False
for
_
in
range
(
self
.
__num_dataset
)]
self
.
__is_predicted_cur_iter
=
[
False
for
_
in
range
(
self
.
__num_dataset
)]
return
self
return
self
def
current_iteration
(
self
):
def
current_iteration
(
self
)
->
int
:
"""Get the index of the current iteration.
"""Get the index of the current iteration.
Returns
Returns
...
@@ -3127,7 +3127,7 @@ class Booster:
...
@@ -3127,7 +3127,7 @@ class Booster:
ctypes
.
byref
(
out_cur_iter
)))
ctypes
.
byref
(
out_cur_iter
)))
return
out_cur_iter
.
value
return
out_cur_iter
.
value
def
num_model_per_iteration
(
self
):
def
num_model_per_iteration
(
self
)
->
int
:
"""Get number of models per iteration.
"""Get number of models per iteration.
Returns
Returns
...
@@ -3141,7 +3141,7 @@ class Booster:
...
@@ -3141,7 +3141,7 @@ class Booster:
ctypes
.
byref
(
model_per_iter
)))
ctypes
.
byref
(
model_per_iter
)))
return
model_per_iter
.
value
return
model_per_iter
.
value
def
num_trees
(
self
):
def
num_trees
(
self
)
->
int
:
"""Get number of weak sub-models.
"""Get number of weak sub-models.
Returns
Returns
...
@@ -3155,7 +3155,7 @@ class Booster:
...
@@ -3155,7 +3155,7 @@ class Booster:
ctypes
.
byref
(
num_trees
)))
ctypes
.
byref
(
num_trees
)))
return
num_trees
.
value
return
num_trees
.
value
def
upper_bound
(
self
):
def
upper_bound
(
self
)
->
float
:
"""Get upper bound value of a model.
"""Get upper bound value of a model.
Returns
Returns
...
@@ -3169,7 +3169,7 @@ class Booster:
...
@@ -3169,7 +3169,7 @@ class Booster:
ctypes
.
byref
(
ret
)))
ctypes
.
byref
(
ret
)))
return
ret
.
value
return
ret
.
value
def
lower_bound
(
self
):
def
lower_bound
(
self
)
->
float
:
"""Get lower bound value of a model.
"""Get lower bound value of a model.
Returns
Returns
...
@@ -3353,7 +3353,7 @@ class Booster:
...
@@ -3353,7 +3353,7 @@ class Booster:
ctypes
.
c_int
(
end_iteration
)))
ctypes
.
c_int
(
end_iteration
)))
return
self
return
self
def
model_from_string
(
self
,
model_str
)
:
def
model_from_string
(
self
,
model_str
:
str
)
->
"Booster"
:
"""Load Booster from a string.
"""Load Booster from a string.
Parameters
Parameters
...
@@ -3665,7 +3665,7 @@ class Booster:
...
@@ -3665,7 +3665,7 @@ class Booster:
new_booster
.
network
=
self
.
network
new_booster
.
network
=
self
.
network
return
new_booster
return
new_booster
def
get_leaf_output
(
self
,
tree_id
,
leaf_id
)
:
def
get_leaf_output
(
self
,
tree_id
:
int
,
leaf_id
:
int
)
->
float
:
"""Get the output of a leaf.
"""Get the output of a leaf.
Parameters
Parameters
...
...
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