PolynomialFeatures
sklearn.preprocessing.PolynomialFeatures 用法
sklearn中數(shù)據(jù)預(yù)處理過(guò)程中的多項(xiàng)式特征構(gòu)造工具包耕捞。
eg:[x1,x2] -> [1,x1,x2,x12,x1*x2,x22]輸入一個(gè)二維樣本围详。產(chǎn)生二階多項(xiàng)式特征瓢捉。
1.參數(shù)理解:(一共只有3個(gè)參數(shù))
- degree : integer
The degree of the polynomial features. Default = 2.
多項(xiàng)式的階數(shù),一般默認(rèn)是2敦锌。
- interaction_only : boolean, default = False
If true, only interaction features are produced: features that are products of at most degree distinct input features (so not x[1] ** 2, x[0] * x[2] ** 3, etc.).
如果值為true(默認(rèn)是false),則會(huì)產(chǎn)生相互影響的特征集绿渣。
- include_bias : boolean
If True (default), then include a bias column, the feature in which all polynomial powers are zero (i.e. a column of ones - acts as an intercept term in a linear model).
是否包含偏差列
2.屬性
- powers_ : array, shape (n_input_features, n_output_features)
powers_[i, j] is the exponent of the jth input in the ith output.
- n_input_features_ : int
The total number of input features.
輸入特征的個(gè)數(shù)
- n_output_features_ : int
The total number of polynomial output features. The number of output features is computed by iterating over all suitably sized combinations of input features.
輸出多項(xiàng)式的特征個(gè)數(shù)。它的計(jì)算是通過(guò)遍歷所有的適當(dāng)大小的輸入特征組合。
3.方法
- fit(X, y=None)
Compute number of output features.
計(jì)算輸出特征的個(gè)數(shù) - fit_transform(X, y=None, **fit_params)
Fit to data, then transform it.