Reputation: 125
I'm trying to do something with feature engineer. So, I try to use the method RFE of Sklearn to do with it. But after I got the dataset who returned by RFE, I have no idea, which features is choosed, and which featured are deleted. So, is there any solution can make me know that?
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]])
Upvotes: 1
Views: 1920
Reputation: 4485
You can use the RFE fitted object:
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
Upvotes: 1