8000 DOC Improve get_feature_names_out docstrings (#22718) · scikit-learn/scikit-learn@279388d · GitHub
[go: up one dir, main page]

Skip to content

Commit 279388d

Browse files
ogriselthomasjpfan
andauthored
DOC Improve get_feature_names_out docstrings (#22718)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
1 parent 7a9677e commit 279388d

File tree

12 files changed

+34
-22
lines changed

12 files changed

+34
-22
lines changed

doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ Methods
12571257
be generated. If `input_features` is not passed in, then the
12581258
`feature_names_in_` attribute will be used. If the
12591259
`feature_names_in_` attribute is not defined, then the
1260-
input names are named `[x0, x1, ..., x(n_features_in_)]`.
1260+
input names are named `[x0, x1, ..., x(n_features_in_ - 1)]`.
12611261

12621262
``get_n_splits``
12631263
On a :term:`CV splitter` (not an estimator), returns the number of

sklearn/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,8 @@ def get_feature_names_out(self, input_features=None):
887887
888888
- If `input_features` is `None`, then `feature_names_in_` is
889889
used as feature names in. If `feature_names_in_` is not defined,
890-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
890+
then the following input feature names are generated:
891+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
891892
- If `input_features` is an array-like, then `input_features` must
892893
match `feature_names_in_` if `feature_names_in_` is defined.
893894

sklearn/compose/_column_transformer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ def get_feature_names_out(self, input_features=None):
463463
464464
- If `input_features` is `None`, then `feature_names_in_` is
465465
used as feature names in. If `feature_names_in_` is not defined,
466-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
466+
then the following input feature names are generated:
467+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
467468
- If `input_features` is an array-like, then `input_features` must
468469
match `feature_names_in_` if `feature_names_in_` is defined.
469470

sklearn/feature_selection/_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def get_feature_names_out(self, input_features=None):
153153
154154
- If `input_features` is `None`, then `feature_names_in_` is
155155
used as feature names in. If `feature_names_in_` is not defined,
156-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
156+
then the following input feature names are generated:
157+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
157158
- If `input_features` is an array-like, then `input_features` must
158159
match `feature_names_in_` if `feature_names_in_` is defined.
159160

sklearn/impute/_base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,11 @@ def get_feature_names_out(self, input_features=None):
643643
Input features.
644644
645645
- If `input_features` is `None`, then `feature_names_in_` is
646-
used as feature names in. If `feature_names_in_` is not defined,
647-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
646+
used as feature names in. If `feature_names_in_` is not defined,
647+
then the following input feature names are generated:
648+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
648649
- If `input_features` is an array-like, then `input_features` must
649-
match `feature_names_in_` if `feature_names_in_` is defined.
650+
match `feature_names_in_` if `feature_names_in_` is defined.
650651
651652
Returns
652653
-------
@@ -994,7 +995,8 @@ def get_feature_names_out(self, input_features=None):
994995
995996
- If `input_features` is `None`, then `feature_names_in_` is
996997
used as feature names in. If `feature_names_in_` is not defined,
997-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
998+
then the following input feature names are generated:
999+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
9981000
- If `input_features` is an array-like, then `input_features` must
9991001
match `feature_names_in_` if `feature_names_in_` is defined.
10001002

sklearn/impute/_iterative.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,10 +785,11 @@ def get_feature_names_out(self, input_features=None):
785785
Input features.
786786
787787
- If `input_features` is `None`, then `feature_names_in_` is
788-
used as feature names in. If `feature_names_in_` is not defined,
789-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
788+
used as feature names in. If `feature_names_in_` is not defined,
789+
then the following input feature names are generated:
790+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
790791
- If `input_features` is an array-like, then `input_features` must
791-
match `feature_names_in_` if `feature_names_in_` is defined.
792+
match `feature_names_in_` if `feature_names_in_` is defined.
792793
793794
Returns
794795
-------

sklearn/impute/_knn.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,11 @@ def get_feature_names_out(self, input_features=None):
350350
Input features.
351351
352352
- If `input_features` is `None`, then `feature_names_in_` is
353-
used as feature names in. If `feature_names_in_` is not defined,
354-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
353+
used as feature names in. If `feature_names_in_` is not defined,
354+
then the following input feature names are generated:
355+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
355356
- If `input_features` is an array-like, then `input_features` must
356-
match `feature_names_in_` if `feature_names_in_` is defined.
357+
match `feature_names_in_` if `feature_names_in_` is defined.
357358
358359
Returns
359360
-------

sklearn/preprocessing/_discretization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ def get_feature_names_out(self, input_features=None):
438438
439439
- If `input_features` is `None`, then `feature_names_in_` is
440440
used as feature names in. If `feature_names_in_` is not defined,
441-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
441+
then the following input feature names are generated:
442+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
442443
- If `input_features` is an array-like, then `input_features` must
443444
match `feature_names_in_` if `feature_names_in_` is defined.
444445

sklearn/preprocessing/_encoders.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ def get_feature_names_out(self, input_features=None):
709709
710710
- If `input_features` is `None`, then `feature_names_in_` is
711711
used as feature names in. If `feature_names_in_` is not defined,
712-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
712+
then the following input feature names are generated:
713+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
713714
- If `input_features` is an array-like, then `input_features` must
714715
match `feature_names_in_` if `feature_names_in_` is defined.
715716

sklearn/preprocessing/_function_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def get_feature_names_out(self, input_features=None):
242242
- If `input_features` is None, then `feature_names_in_` is
243243
used as the input feature names. If `feature_names_in_` is not
244244
defined, then names are generated:
245-
`[x0, x1, ..., x(n_features_in_)]`.
245+
`[x0, x1, ..., x(n_features_in_ - 1)]`.
246246
- If `input_features` is array-like, then `input_features` must
247247
match `feature_names_in_` if `feature_names_in_` is defined.
248248

sklearn/preprocessing/_polynomial.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def get_feature_names_out(self, input_features=None):
240240
241241
- If `input_features is None`, then `feature_names_in_` is
242242
used as feature names in. If `feature_names_in_` is not defined,
243-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
243+
then the following input feature names are generated:
244+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
244245
- If `input_features` is an array-like, then `input_features` must
245246
match `feature_names_in_` if `feature_names_in_` is defined.
246247
@@ -713,7 +714,8 @@ def get_feature_names_out(self, input_features=None):
713714
714715
- If `input_features` is `None`, then `feature_names_in_` is
715716
used as feature names in. If `feature_names_in_` is not defined,
716-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
717+
then the following input feature names are generated:
718+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
717719
- If `input_features` is an array-like, then `input_features` must
718720
match `feature_names_in_` if `feature_names_in_` is defined.
719721

sklearn/utils/validation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,11 @@ def _check_feature_names_in(estimator, input_features=None, *, generate_names=Tr
18711871
Input features.
18721872
18731873
- If `input_features` is `None`, then `feature_names_in_` is
1874-
used as feature names in. If `feature_names_in_` is not defined,
1875-
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
1874+
used as feature names in. If `feature_names_in_` is not defined,
1875+
then the following input feature names are generated:
1876+
`["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
18761877
- If `input_features` is an array-like, then `input_features` must
1877-
match `feature_names_in_` if `feature_names_in_` is defined.
1878+
match `feature_names_in_` if `feature_names_in_` is defined.
18781879
18791880
generate_names : bool, default=True
18801881
Whether to generate names when `input_features` is `None` and

0 commit comments

Comments
 (0)
0