当我使用 skLearn 的 RFE 时如何知道返回了哪一列

How to know which column returned when I use RFE of skLearn

我正在尝试与功能工程师合作。所以,我尝试使用Sklearn的RFE方法来处理它。但是拿到RFE返回的数据集后,我就不知道了,选了哪些features,删除了哪些features。那么,有什么办法可以让我知道吗?

v = trainDF.loc[:,['A','B','C','D']].as_matrix()
t = trainDF.loc[:,['y']].values.ravel()
RFE(estimator=LogisticRegression(), n_features_to_select=3).fit_transform(v,t)

=>

array([[2, 0, 0],
       [4, 0, 0],
       [1, 0, 0],
       ..., 
       [2, 0, 0],
       [1, 0, 0],
       [3, 0, 0]])

可以使用RFE拟合对象:

estimator = RFE(estimator=LogisticRegression(), n_features_to_select=3)
v_transform = estimator.fit_transform(v,t)
print(estimator.support_)  # The mask of selected features.
print(estimator.ranking_)  # The feature ranking