有没有办法从下面的代码片段中提取实际的特征重要性系数/分数(与顶级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)发布于 2020-06-25 08:20:40
如果您的目标是提取已适合最终简化数据集的估计器的特征重要性,则可以使用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_,这取决于所使用的估计器。
https://stackoverflow.com/questions/62565467
复制相似问题