MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / PolynomialFeatures

Class PolynomialFeatures

sklearn/preprocessing/_polynomial.py:92–583  ·  view source on GitHub ↗

Generate polynomial and interaction features. Generate a new feature matrix consisting of all polynomial combinations of the features with degree less than or equal to the specified degree. For example, if an input sample is two dimensional and of the form [a, b], the degree-2 polyn

Source from the content-addressed store, hash-verified

90
91
92class PolynomialFeatures(TransformerMixin, BaseEstimator):
93 """Generate polynomial and interaction features.
94
95 Generate a new feature matrix consisting of all polynomial combinations
96 of the features with degree less than or equal to the specified degree.
97 For example, if an input sample is two dimensional and of the form
98 [a, b], the degree-2 polynomial features are [1, a, b, a^2, ab, b^2].
99
100 Read more in the :ref:`User Guide <polynomial_features>`.
101
102 Parameters
103 ----------
104 degree : int or tuple (min_degree, max_degree), default=2
105 If a single int is given, it specifies the maximal degree of the
106 polynomial features. If a tuple `(min_degree, max_degree)` is passed,
107 then `min_degree` is the minimum and `max_degree` is the maximum
108 polynomial degree of the generated features. Note that `min_degree=0`
109 and `min_degree=1` are equivalent as outputting the degree zero term is
110 determined by `include_bias`.
111
112 interaction_only : bool, default=False
113 If `True`, only interaction features are produced: features that are
114 products of at most `degree` *distinct* input features, i.e. terms with
115 power of 2 or higher of the same input feature are excluded:
116
117 - included: `x[0]`, `x[1]`, `x[0] * x[1]`, etc.
118 - excluded: `x[0] ** 2`, `x[0] ** 2 * x[1]`, etc.
119
120 include_bias : bool, default=True
121 If `True` (default), then include a bias column, the feature in which
122 all polynomial powers are zero (i.e. a column of ones - acts as an
123 intercept term in a linear model).
124
125 order : {'C', 'F'}, default='C'
126 Order of output array in the dense case. `'F'` order is faster to
127 compute, but may slow down subsequent estimators.
128
129 .. versionadded:: 0.21
130
131 Attributes
132 ----------
133 powers_ : ndarray of shape (`n_output_features_`, `n_features_in_`)
134 `powers_[i, j]` is the exponent of the jth input in the ith output.
135
136 n_features_in_ : int
137 Number of features seen during :term:`fit`.
138
139 .. versionadded:: 0.24
140
141 feature_names_in_ : ndarray of shape (`n_features_in_`,)
142 Names of features seen during :term:`fit`. Defined only when `X`
143 has feature names that are all strings.
144
145 .. versionadded:: 1.0
146
147 n_output_features_ : int
148 The total number of polynomial output features. The number of output
149 features is computed by iterating over all suitably sized combinations

Calls 2

IntervalClass · 0.90
StrOptionsClass · 0.90

Used in the wild real call sites across dependent graphs

searching dependent graphs…