@@ -42,35 +42,35 @@ class PolynomialFeatures(TransformerMixin, BaseEstimator):
42
42
----------
43
43
degree : int or tuple (min_degree, max_degree), default=2
44
44
If a single int is given, it specifies the maximal degree of the
45
- polynomial features. If a tuple `` (min_degree, max_degree)`` is
46
- passed, then `` min_degree`` is the minimum and `` max_degree`` is the
47
- maximum polynomial degree of the generated features. Note that
48
- min_degree=0 and 1 are equivalent as outputting the degree zero term
49
- is determined by `` include_bias` `.
45
+ polynomial features. If a tuple `(min_degree, max_degree)` is passed,
46
+ then `min_degree` is the minimum and `max_degree` is the maximum
47
+ polynomial degree of the generated features. Note that `min_degree=0`
48
+ and `min_degree=1` are equivalent as outputting the degree zero term is
49
+ determined by `include_bias`.
50
50
51
51
interaction_only : bool, default=False
52
- If true , only interaction features are produced: features that are
53
- products of at most `` degree`` *distinct* input features, i.e. terms
54
- with power of 2 or higher of the same input feature are excluded:
52
+ If `True` , only interaction features are produced: features that are
53
+ products of at most `degree` *distinct* input features, i.e. terms with
54
+ power of 2 or higher of the same input feature are excluded:
55
55
56
- - included: `` x[0]`` , `x[1]`, `` x[0] * x[1]` `, etc.
57
- - excluded: `` x[0] ** 2`` , `` x[0] ** 2 * x[1]` `, etc.
56
+ - included: `x[0]`, `x[1]`, `x[0] * x[1]`, etc.
57
+ - excluded: `x[0] ** 2`, `x[0] ** 2 * x[1]`, etc.
58
58
59
59
include_bias : bool, default=True
60
- If True (default), then include a bias column, the feature in which
60
+ If ` True` (default), then include a bias column, the feature in which
61
61
all polynomial powers are zero (i.e. a column of ones - acts as an
62
62
intercept term in a linear model).
63
63
64
64
order : {'C', 'F'}, default='C'
65
- Order of output array in the dense case. 'F' order is faster to
65
+ Order of output array in the dense case. ` 'F'` order is faster to
66
66
compute, but may slow down subsequent estimators.
67
67
68
68
.. versionadded:: 0.21
69
69
70
70
Attributes
71
71
----------
72
72
powers_ : ndarray of shape (`n_output_features_`, `n_features_in_`)
73
- powers_[i, j] is the exponent of the jth input in the ith output.
73
+ ` powers_[i, j]` is the exponent of the jth input in the ith output.
74
74
75
75
n_input_features_ : int
76
76
The total number of input features.
@@ -98,7 +98,7 @@ class PolynomialFeatures(TransformerMixin, BaseEstimator):
98
98
See Also
99
99
--------
100
100
SplineTransformer : Transformer that generates univariate B-spline bases
101
- for features
101
+ for features.
102
102
103
103
Notes
104
104
-----
@@ -181,6 +181,7 @@ def _num_combinations(
181
181
182
182
@property
183
183
def powers_ (self ):
184
+ """Exponent for each of the inputs in the output."""
184
185
check_is_fitted (self )
185
186
186
187
combinations = self ._combinations (
@@ -199,8 +200,7 @@ def powers_(self):
199
200
"in 1.2. Please use get_feature_names_out instead."
200
201
)
201
202
def get_feature_names (self , input_features = None ):
202
- """
203
- Return feature names for output features
203
+ """Return feature names for output features.
204
204
205
205
Parameters
206
206
----------
@@ -211,6 +211,7 @@ def get_feature_names(self, input_features=None):
211
211
Returns
212
212
-------
213
213
output_feature_names : list of str of shape (n_output_features,)
214
+ Transformed feature names.
214
215
"""
215
216
powers = self .powers_
216
217
if input_features is None :
@@ -238,7 +239,7 @@ def get_feature_names_out(self, input_features=None):
238
239
input_features : array-like of str or None, default=None
239
240
Input features.
240
241
241
- - If `input_features` is ` None`, then `feature_names_in_` is
242
+ - If `input_features is None`, then `feature_names_in_` is
242
243
used as feature names in. If `feature_names_in_` is not defined,
243
244
then names are generated: `[x0, x1, ..., x(n_features_in_)]`.
244
245
- If `input_features` is an array-like, then `input_features` must
@@ -270,14 +271,13 @@ def fit(self, X, y=None):
270
271
"""
271
272
Compute number of output features.
272
273
273
-
274
274
Parameters
275
275
----------
276
276
X : {array-like, sparse matrix} of shape (n_samples, n_features)
277
277
The data.
278
278
279
- y : None
280
- Ignored .
279
+ y : Ignored
280
+ Not used, present here for API consistency by convention .
281
281
282
282
Returns
283
283
-------
@@ -359,10 +359,10 @@ def transform(self, X):
359
359
Returns
360
360
-------
361
361
XP : {ndarray, sparse matrix} of shape (n_samples, NP)
362
- The matrix of features, where NP is the number of polynomial
362
+ The matrix of features, where `NP` is the number of polynomial
363
363
features generated from the combination of inputs. If a sparse
364
364
matrix is provided, it will be converted into a sparse
365
- `` csr_matrix` `.
365
+ `csr_matrix`.
366
366
"""
367
367
check_is_fitted (self )
368
368
0 commit comments