Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklamiller committed Mar 28, 2024
1 parent 4c1d9b0 commit 10d5301
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,17 +1118,17 @@ 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]: The names of features.
.. note::
If input does not contain feature names, they will be added during fitting in the format ``Column_0``, ``Column_1``, ..., ``Column_N``.
"""
if not self.__sklearn_is_fitted__():
raise LGBMNotFittedError('No feature_names_in_ found. Need to call fit beforehand.')
if not self.__sklearn_is_fitted__():
raise LGBMNotFittedError("No feature_names_in_ found. Need to call fit beforehand.")
return self.feature_name_


Expand Down
4 changes: 1 addition & 3 deletions tests/python_package_test/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,9 +1284,7 @@ def test_getting_feature_names_in_np_input():
with pytest.raises(lgb.compat.LGBMNotFittedError):
est.feature_names_in_
est.fit(X, y)
assert est.feature_names_in_ == [
f"Column_{i}" for i in range(X.shape[1])
]
assert est.feature_names_in_ == [f"Column_{i}" for i in range(X.shape[1])]


def test_getting_feature_names_in_pd_input():
Expand Down

0 comments on commit 10d5301

Please sign in to comment.