导航菜单

数据挖掘/特征工程
课程进度 23% · 第3/10章3/10章 · 标签 1/3
1

特征选择

过滤法

python
1
from sklearn.feature_selection import SelectKBest, chi2, f_classif
2
# 卡方检验
3
skb = SelectKBest(chi2, k=10)
4
X_selected = skb.fit_transform(X, y)
5
# 方差分析
6
skb = SelectKBest(f_classif, k=10)

包装法

python
1
from sklearn.feature_selection import RFE
2
from sklearn.svm import SVC
3
rfe = RFE(estimator=SVC(), n_features_to_select=10)
4
rfe.fit(X, y)
5
print(rfe.support_)
2