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
f585eafa
Unverified
Commit
f585eafa
authored
Mar 08, 2023
by
James Lamb
Committed by
GitHub
Mar 08, 2023
Browse files
[python-package] add type hints on sklearn properties (#5771)
parent
0cff4f83
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
python-package/lightgbm/sklearn.py
python-package/lightgbm/sklearn.py
+6
-6
No files found.
python-package/lightgbm/sklearn.py
View file @
f585eafa
...
...
@@ -534,7 +534,7 @@ class LGBMModel(_LGBMModelBase):
self
.
_class_map
:
Optional
[
Dict
[
int
,
int
]]
=
None
self
.
_n_features
:
int
=
-
1
self
.
_n_features_in
:
int
=
-
1
self
.
_classes
=
None
self
.
_classes
:
Optional
[
np
.
ndarray
]
=
None
self
.
_n_classes
:
Optional
[
int
]
=
None
self
.
set_params
(
**
kwargs
)
...
...
@@ -952,7 +952,7 @@ class LGBMModel(_LGBMModelBase):
return
self
.
_Booster
.
current_iteration
()
# type: ignore
@
property
def
booster_
(
self
):
def
booster_
(
self
)
->
Booster
:
"""Booster: The underlying Booster of this model."""
if
not
self
.
__sklearn_is_fitted__
():
raise
LGBMNotFittedError
(
'No booster found. Need to call fit beforehand.'
)
...
...
@@ -966,7 +966,7 @@ class LGBMModel(_LGBMModelBase):
return
self
.
_evals_result
@
property
def
feature_importances_
(
self
):
def
feature_importances_
(
self
)
->
np
.
ndarray
:
""":obj:`array` of shape = [n_features]: The feature importances (the higher, the more important).
.. note::
...
...
@@ -979,8 +979,8 @@ class LGBMModel(_LGBMModelBase):
return
self
.
_Booster
.
feature_importance
(
importance_type
=
self
.
importance_type
)
@
property
def
feature_name_
(
self
):
""":obj:`
array
` of shape = [n_features]: The names of features."""
def
feature_name_
(
self
)
->
List
[
str
]
:
""":obj:`
list
` of shape = [n_features]: The names of features."""
if
not
self
.
__sklearn_is_fitted__
():
raise
LGBMNotFittedError
(
'No feature_name found. Need to call fit beforehand.'
)
return
self
.
_Booster
.
feature_name
()
...
...
@@ -1195,7 +1195,7 @@ class LGBMClassifier(_LGBMClassifierBase, LGBMModel):
)
@
property
def
classes_
(
self
):
def
classes_
(
self
)
->
np
.
ndarray
:
""":obj:`array` of shape = [n_classes]: The class label array."""
if
not
self
.
__sklearn_is_fitted__
():
raise
LGBMNotFittedError
(
'No classes found. Need to call fit beforehand.'
)
...
...
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