Python 提取特征重要性系数/分数

Python 提取特征重要性系数/分数,python,scikit-learn,feature-selection,sklearn-pandas,rfe,Python,Scikit Learn,Feature Selection,Sklearn Pandas,Rfe,是否有任何方法可以从以下代码片段中提取实际的功能重要性系数/分数(与顶部的num_feats功能相反) 如果您的目标是提取适合最终简化数据集的估计器的特征重要性,您可以使用估计器属性访问该估计器,并提取其系数或特征重要性分数: from sklearn.feature_selection import RFE from sklearn.linear_model import LogisticRegression rfe_selector = RFE(estimator=LogisticRegr

是否有任何方法可以从以下代码片段中提取实际的功能重要性系数/分数(与顶部的
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)

coefs = rfe_selector.estimator_.coef_[0]
当然,如果必须调用
coef\uu
feature\u importances\uu
,这取决于所使用的估计器

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]