Unverified Commit a2a38b6c authored by Alex's avatar Alex Committed by GitHub
Browse files

[python][scikit-learn] add new attribute for used number of features (#3129)

* update number of features attribute

Fixes issue related to https://github.com/scikit-learn/scikit-learn/issues/17353 (see SLEP010 https://scikit-learn-enhancement-proposals.readthedocs.io/en/latest/slep010/proposal.html

).

* Update sklearn.py

* set public attribute in fit method

Reverted ```n_features``` property, and inserted the public attribute ```n_features_in_```.

* Update documentation

* Update python-package/lightgbm/sklearn.py
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
parent 075513fa
......@@ -257,6 +257,8 @@ class LGBMModel(_LGBMModelBase):
----------
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
......@@ -563,6 +565,8 @@ class LGBMModel(_LGBMModelBase):
sample_weight = np.multiply(sample_weight, class_sample_weight)
self._n_features = _X.shape[1]
# set public attribute for consistency
self.n_features_in_ = self._n_features
def _construct_dataset(X, y, sample_weight, init_score, group, params,
categorical_feature='auto'):
......
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