Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/requirements_base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx == 3.0.2
sphinx
sphinx_rtd_theme >= 0.3
mock; python_version < '3'
2 changes: 1 addition & 1 deletion docs/requirements_rtd.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx == 3.0.2
sphinx >= 3.0.2
sphinx_rtd_theme >= 0.3
mock; python_version < '3'
breathe
40 changes: 10 additions & 30 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,8 @@ def __init__(self, boosting_type='gbdt', num_leaves=31, max_depth=-1,

Attributes
----------
n_features_ : int
The number of features of fitted model.
n_features_in_ : int
The number of features of fitted model.
classes_ : array of shape = [n_classes]
The class label array (only for classification problem).
n_classes_ : int
The number of classes (only for classification problem).
best_score_ : dict or None
The best score of fitted model.
best_iteration_ : int or None
The best iteration of fitted model if ``early_stopping_rounds`` has been specified.
objective_ : string or callable
The concrete objective used while fitting this model.
booster_ : Booster
The underlying Booster of this model.
evals_result_ : dict or None
The evaluation results if ``early_stopping_rounds`` has been specified.
feature_importances_ : array of shape = [n_features]
The feature importances (the higher, the more important the feature).
feature_name_ : array of shape = [n_features]
The names of features.

Note
----
Expand Down Expand Up @@ -690,49 +670,49 @@ def predict(self, X, raw_score=False, num_iteration=None,

@property
def n_features_(self):
"""Get the number of features of fitted model."""
""":obj:`int`: The number of features of fitted model."""
if self._n_features is None:
raise LGBMNotFittedError('No n_features found. Need to call fit beforehand.')
return self._n_features

@property
def best_score_(self):
"""Get the best score of fitted model."""
""":obj:`dict` or :obj:`None`: The best score of fitted model."""
if self._n_features is None:
raise LGBMNotFittedError('No best_score found. Need to call fit beforehand.')
return self._best_score

@property
def best_iteration_(self):
"""Get the best iteration of fitted model."""
""":obj:`int` or :obj:`None`: The best iteration of fitted model if ``early_stopping_rounds`` has been specified."""
if self._n_features is None:
raise LGBMNotFittedError('No best_iteration found. Need to call fit with early_stopping_rounds beforehand.')
return self._best_iteration

@property
def objective_(self):
"""Get the concrete objective used while fitting this model."""
""":obj:`string` or :obj:`callable`: The concrete objective used while fitting this model."""
if self._n_features is None:
raise LGBMNotFittedError('No objective found. Need to call fit beforehand.')
return self._objective

@property
def booster_(self):
"""Get the underlying lightgbm Booster of this model."""
"""Booster: The underlying Booster of this model."""
if self._Booster is None:
raise LGBMNotFittedError('No booster found. Need to call fit beforehand.')
return self._Booster

@property
def evals_result_(self):
"""Get the evaluation results."""
""":obj:`dict` or :obj:`None`: The evaluation results if ``early_stopping_rounds`` has been specified."""
if self._n_features is None:
raise LGBMNotFittedError('No results found. Need to call fit with eval_set beforehand.')
return self._evals_result

@property
def feature_importances_(self):
"""Get feature importances.
""":obj:`array` of shape = [n_features]: The feature importances (the higher, the more important).

.. note::

Expand All @@ -745,7 +725,7 @@ def feature_importances_(self):

@property
def feature_name_(self):
"""Get feature name."""
""":obj:`array` of shape = [n_features]: The names of features."""
if self._n_features is None:
raise LGBMNotFittedError('No feature_name found. Need to call fit beforehand.')
return self._Booster.feature_name()
Expand Down Expand Up @@ -907,14 +887,14 @@ def predict_proba(self, X, raw_score=False, num_iteration=None,

@property
def classes_(self):
"""Get the class label array."""
""":obj:`array` of shape = [n_classes]: The class label array."""
if self._classes is None:
raise LGBMNotFittedError('No classes found. Need to call fit beforehand.')
return self._classes

@property
def n_classes_(self):
"""Get the number of classes."""
""":obj:`int`: The number of classes."""
if self._n_classes is None:
raise LGBMNotFittedError('No classes found. Need to call fit beforehand.')
return self._n_classes
Expand Down