提取特征重要性 Coefficients/Scores

Extracting Feature Importance Coefficients/Scores

是否有任何方法可以从以下代码片段中提取实际特征重要性 coefficients/scores(与顶级 num_feats 特征相反)?

from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
rfe_selector = RFE(estimator=LogisticRegression(), n_features_to_select=num_feats, step=10, verbose=5)
rfe_selector.fit(X_norm, y)

如果您的目标是提取适合最终缩减数据集的估计器的特征重要性,您可以使用 estimator_ 属性访问此估计器并提取其系数或特征重要性分数:

from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression

rfe_selector = RFE(estimator=LogisticRegression(), n_features_to_select=num_feats, step=10, verbose=5)
rfe_selector.fit(X_norm, y)

coefs = rfe_selector.estimator_.coef_[0]

当然要调用coef_还是feature_importances_.

当然要看使用的estimator