问题描述
我已使用电源变压器转换了数据集(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()吗?