Skip to content

Commit

Permalink
expose feature_name_ via sklearn consistent attribute feature_names_in_
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklamiller committed Feb 12, 2024
1 parent cc733f8 commit c481290
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,11 @@ def feature_name_(self) -> List[str]:
if not self.__sklearn_is_fitted__():
raise LGBMNotFittedError('No feature_name found. Need to call fit beforehand.')
return self._Booster.feature_name() # type: ignore[union-attr]

@property
def feature_names_in_(self) -> List[str]:
""":obj:`list` of shape = [n_features]: Sklearn-style property for feature names."""
return self.feature_name_


class LGBMRegressor(_LGBMRegressorBase, LGBMModel):
Expand Down

0 comments on commit c481290

Please sign in to comment.