我正在使用PCA对特征进行预处理,以使用决策树作为基础学习器(如正交特征)来使用xgboost库执行分类。
xgboost软件包提供了功能重要性评估(feature_importances_,例如通过“ gain”获得);我的问题是,现在我如何才能将PC(功能)的重要性转换为原始功能空间中的功能。
X是我的特征矩阵,y是我的标签向量
# split data into train and test data
Xtrain, Xtest, ytrain, ytest = sklearn.model_selection.train_test_split(X, y, stratify=y, test_size=0.2,
random_state=123)
# standardize features
scaler = sklearn.preprocessing.StandardScaler()
scaler.fit(Xtrain)
sXtrain = scaler.transform(Xtrain)
sXtest = scaler.transform(Xtest)
# PCA transform
pca_trans = sklearn.decomposition.PCA()
tXtrain = pca_trans.fit(sXtrain)
tXtrain = pca_trans.transform(sXtrain)
tXtest = pca_trans.transform(sXtest)
# define and fit xgbooster
xgb_clas_t = xgb.XGBClassifier(seed=0)
xgb_clas_t.fit(tXtrain,ytrain)
xgb_clas_t.feature_importances_ # feature importances of PC - how to transform these back to original space?