简体   繁体   English

迭代 RFE 分数 sklearn

[英]Iterative RFE scores sklearn

I'm using RFE with ExtraTreeRegressor as estimator in order to make SupervisedFeatureSelection in a regression problem.我使用带有 ExtraTreeRegressor 的 RFE 作为估计器,以便在回归问题中进行 SupervisedFeatureSelection。

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.我想要的是更深入的信息,即 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.我注意到有一些像 _fit 这样的隐藏函数,我正在考虑试图强制 step_score 参数与无不同......关键是我无法达到我想要的......(我是 python 新手......)我想在每次迭代时打印分数。 Is there anyone who have experience with such a task?有没有人有过这样的任务的经验? What should be a proper value of the step_score parameter? step_score 参数的正确值应该是多少? ( I've tried with a boolean but it doesn't work ) (我试过用一个布尔值,但它不起作用)

Thanks for any advice!!!感谢您的任何建议!!!

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_

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM