3
votes

I'm using RFE with ExtraTreeRegressor as estimator in order to make SupervisedFeatureSelection in a regression problem.

I get the ranking and the support from the model with the common code below:

rfe_vola = RFE(estimator=ExtraTreesRegressor(), n_features_to_select=1, step=1)
rfe_vola.fit(X_allfeatures, y_vol)
ranking_vola = rfe_vola.ranking_
print("ranking: ",ranking_vola)
print("support: ",rfe_vola.support_)

what I would like to have, is a deeper information, thus the scores or the features evaluation at each iteration of RFE. I've noticed that there are some hidden function like _fit, and I'm thinking in trying to force the step_score parameter to be different from none... The point is that I'm not able to reach what I want.. (I'm new to python...) I would like to get the print of the scores at each iteration. Is there anyone who have experience with such a task? What should be a proper value of the step_score parameter? ( I've tried with a boolean but it doesn't work )

Thanks for any advice!!!

1

1 Answers

3
votes

That is was I was looking for:

from sklearn.metrics import r2_score

rfe_vola = RFE(estimator=ExtraTreesRegressor(),n_features_to_select=None, step=1, verbose=2)    
r2_scorer = lambda est, features: r2_score(y_true=y_vol,y_pred=est.predict(X_allfeatures[:, features]))
rfe_vola._fit(X_allfeatures, y_vol, r2_scorer)
ranking_vola = rfe_vola.ranking_