Wrapper Methods
1. 方法原理
2. 常見策略
a. 前向選擇(Forward Selection)
from sklearn.datasets import load_iris
from sklearn.feature_selection import SequentialFeatureSelector
from sklearn.linear_model import LogisticRegression
X, y = load_iris(return_X_y=True)
model = LogisticRegression(max_iter=200)
sfs = SequentialFeatureSelector(model, n_features_to_select=2, direction='forward')
sfs.fit(X, y)
print("選中的特徵索引:", sfs.get_support())b. 後向刪除(Backward Elimination)
c. 遞迴特徵消除(Recursive Feature Elimination, RFE)
d. 遺傳演算法(Genetic Algorithm)
3. 優缺點比較
優點
缺點
4. Python 範例:遞迴特徵消除(RFE)
5. 應用情境
Last updated