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
da5160cf
Unverified
Commit
da5160cf
authored
Mar 31, 2023
by
James Lamb
Committed by
GitHub
Mar 31, 2023
Browse files
[python-package] add more type annotations in basic.py (#5812)
parent
6de94ef8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+12
-11
No files found.
python-package/lightgbm/basic.py
View file @
da5160cf
...
@@ -1735,9 +1735,9 @@ class Dataset:
...
@@ -1735,9 +1735,9 @@ class Dataset:
def
_set_init_score_by_predictor
(
def
_set_init_score_by_predictor
(
self
,
self
,
predictor
:
Optional
[
_InnerPredictor
],
predictor
:
Optional
[
_InnerPredictor
],
data
,
data
:
_LGBM_TrainDataType
,
used_indices
:
Optional
[
List
[
int
]]
used_indices
:
Optional
[
List
[
int
]]
):
)
->
"Dataset"
:
data_has_header
=
False
data_has_header
=
False
if
isinstance
(
data
,
(
str
,
Path
))
and
self
.
params
is
not
None
:
if
isinstance
(
data
,
(
str
,
Path
))
and
self
.
params
is
not
None
:
# check data has header or not
# check data has header or not
...
@@ -1769,6 +1769,7 @@ class Dataset:
...
@@ -1769,6 +1769,7 @@ class Dataset:
else
:
else
:
return
self
return
self
self
.
set_init_score
(
init_score
)
self
.
set_init_score
(
init_score
)
return
self
def
_lazy_init
(
def
_lazy_init
(
self
,
self
,
...
@@ -1778,9 +1779,9 @@ class Dataset:
...
@@ -1778,9 +1779,9 @@ class Dataset:
weight
:
Optional
[
_LGBM_WeightType
]
=
None
,
weight
:
Optional
[
_LGBM_WeightType
]
=
None
,
group
:
Optional
[
_LGBM_GroupType
]
=
None
,
group
:
Optional
[
_LGBM_GroupType
]
=
None
,
init_score
:
Optional
[
_LGBM_InitScoreType
]
=
None
,
init_score
:
Optional
[
_LGBM_InitScoreType
]
=
None
,
predictor
=
None
,
predictor
:
Optional
[
_InnerPredictor
]
=
None
,
feature_name
=
'auto'
,
feature_name
:
_LGBM_FeatureNameConfiguration
=
'auto'
,
categorical_feature
=
'auto'
,
categorical_feature
:
_LGBM_CategoricalFeatureConfiguration
=
'auto'
,
params
:
Optional
[
Dict
[
str
,
Any
]]
=
None
params
:
Optional
[
Dict
[
str
,
Any
]]
=
None
)
->
"Dataset"
:
)
->
"Dataset"
:
if
data
is
None
:
if
data
is
None
:
...
@@ -1789,10 +1790,10 @@ class Dataset:
...
@@ -1789,10 +1790,10 @@ class Dataset:
if
reference
is
not
None
:
if
reference
is
not
None
:
self
.
pandas_categorical
=
reference
.
pandas_categorical
self
.
pandas_categorical
=
reference
.
pandas_categorical
categorical_feature
=
reference
.
categorical_feature
categorical_feature
=
reference
.
categorical_feature
data
,
feature_name
,
categorical_feature
,
self
.
pandas_categorical
=
_data_from_pandas
(
data
,
data
,
feature_name
,
categorical_feature
,
self
.
pandas_categorical
=
_data_from_pandas
(
data
=
data
,
feature_name
,
feature_name
=
feature_name
,
categorical_feature
,
categorical_feature
=
categorical_feature
,
self
.
pandas_categorical
)
pandas_categorical
=
self
.
pandas_categorical
)
# process for args
# process for args
params
=
{}
if
params
is
None
else
params
params
=
{}
if
params
is
None
else
params
...
@@ -2340,7 +2341,7 @@ class Dataset:
...
@@ -2340,7 +2341,7 @@ class Dataset:
def
set_field
(
def
set_field
(
self
,
self
,
field_name
:
str
,
field_name
:
str
,
data
data
:
Optional
[
Union
[
List
[
List
[
float
]],
List
[
List
[
int
]],
List
[
float
],
List
[
int
],
np
.
ndarray
,
pd_Series
,
pd_DataFrame
]]
)
->
"Dataset"
:
)
->
"Dataset"
:
"""Set property into the Dataset.
"""Set property into the Dataset.
...
@@ -2540,7 +2541,7 @@ class Dataset:
...
@@ -2540,7 +2541,7 @@ class Dataset:
raise
LightGBMError
(
"Cannot set reference after freed raw data, "
raise
LightGBMError
(
"Cannot set reference after freed raw data, "
"set free_raw_data=False when construct Dataset to avoid this."
)
"set free_raw_data=False when construct Dataset to avoid this."
)
def
set_feature_name
(
self
,
feature_name
:
Union
[
List
[
str
],
str
]
)
->
"Dataset"
:
def
set_feature_name
(
self
,
feature_name
:
_LGBM_FeatureNameConfiguration
)
->
"Dataset"
:
"""Set feature name.
"""Set feature name.
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