有没有办法在模型拟合后检索 SequentialFeatureSelection 的系数?

问题描述 投票:0回答:1

我正在尝试进行特征选择,以识别与响应相关的特征。到目前为止,我已经使用了 sklearn 中的 RFE、RFECV、SelectFromModel 和 SequentialFeatureSelection。模型拟合后,选择器的估计器属性允许我获得除 SequentialFeatureSelection 之外的所有模型的结果系数。有解决办法吗?

我尝试将其与其他模型进行比较,但似乎选择器的估计器属性不适用于 SequentialFeatureSelection。分数属性也没有帮助。还有别的办法吗?

RFE:

estimator = LinearRegression()
selector = RFE(estimator, n_features_to_select=3, step=1)
selector = selector.fit(df[features], df.Y)
coef = selector.estimator_.coef_

SFS:

sfs = SequentialFeatureSelector(estimator, n_features_to_select=3, scoring=(make_scorer(R_squared)))
selector = sfs.fit(df[features], df.Y)
coef = ?
python machine-learning scikit-learn feature-selection
1个回答
0
投票

根据官方文档,SFS 是基于 CV 分数。但是我们可以通过向“评分”参数提供度量/函数来更改默认评分方法。

https://scikit-learn.org/stable/auto_examples/feature_selection/plot_select_from_model_diabetes.html#sphx-glr-auto-examples-feature-selection-plot-select-from-model-diabetes-py

“考虑到 SFS 根本不使用系数,这是非常值得注意的。”

© www.soinside.com 2019 - 2024. All rights reserved.