Unverified Commit 87b6396d authored by zhangqibot's avatar zhangqibot Committed by GitHub
Browse files

[python] add property: feature_name_ in lgb sklearn api (#2740)

* add property: feature_name_ in lgb sklearn api

* modify the comments

* fix linting errors and add info about new attribute: feature_name_
parent dbb804f2
......@@ -269,6 +269,8 @@ class LGBMModel(_LGBMModelBase):
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
----
......@@ -729,6 +731,13 @@ class LGBMModel(_LGBMModelBase):
raise LGBMNotFittedError('No feature_importances found. Need to call fit beforehand.')
return self._Booster.feature_importance(importance_type=self.importance_type)
@property
def feature_name_(self):
"""Get feature name."""
if self._n_features is None:
raise LGBMNotFittedError('No feature_name found. Need to call fit beforehand.')
return self._Booster.feature_name()
class LGBMRegressor(LGBMModel, _LGBMRegressorBase):
"""LightGBM regressor."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment