【发布时间】:2020-12-07 09:02:11
【问题描述】:
我已经使用 power transformer 转换了我的数据集(有 9 列)以生成标准化的高斯分布。
from sklearn.preprocessing import PowerTransformer
pt = PowerTransformer(method='yeo-johnson',standardize=True)
#you can get the original data back using inverse_transform(X)
X_train=pt.fit_transform(X_train)
#fit the model only on the train set and transform the test set
X_test=pt.transform(X_test)
所以现在我的数据集对于大多数零均值和单位方差的特征几乎呈高斯分布。然后我应用了 PolynomialFeatures():
from sklearn.preprocessing import PolynomialFeatures
poly = PolynomialFeatures(degree = 4)
X_poly = poly.fit_transform(X_train)
LR2 = LinearRegression()
LR2.fit(X_poly, y_train)
添加多项式特征后,我有 2380 列可能导致过度拟合,因此我想使用 PCA 进行降维,但我在某处读到 PCA 需要“缩放”数据(这通常意味着使用 MinMaxScaler() 之类的方法更改值的范围。
那么在将 PCA 应用于 boxcox 转换(和标准化)数据集之前,我应该使用 MinMaxScaler() 吗?
【问题讨论】:
标签: python transformation scaling pca