M2-067M2: Classical Machine LearningFeature SelectionEasy
⚡Flashcard Drill➔Mastery:
Comparing Filter, Wrapper, and Embedded Feature Selection Methods
📐 Mathematical Definition
⚡ One-Sentence Core Answer
Filter methods use statistical metrics independently of models; wrapper methods optimize feature subsets iteratively via model performance; embedded methods integrate selection into training.
📌 Key Takeaways
- •Filter: fast, model-agnostic, ignores feature interactions and joint redundancy
- •Wrapper: high performance, considers interactions, computationally expensive (RFE, forward search)
- •Embedded: optimal balance, performed during model training (Lasso, tree importance)
📐 Mathematical Derivations
Categorization of Feature Selection: ① Filter Methods: Rank features by individual statistical association with the target without training downstream models. Metrics include Pearson correlation, ANOVA -test, Mutual Information , or Chi-Square . Cost: . ② Wrapper Methods: Treat feature selection as a combinatorial search problem using the learning algorithm as an evaluation oracle. Examples: Recursive Feature Elimination (RFE), Sequential Forward Selection (SFS). Cost: . ③ Embedded Methods: Feature selection occurs natively during parameter estimation. Examples: L1 regularization inducing exact sparsity, and GBDT split importance gain.
🏭 Production Trade-offs
Practical pipeline selection: In high-dimensional regimes (), first apply Filter methods to eliminate noise and reduce dimensions to manageable scales (). Next, apply Embedded regularization or Wrapper RFE to refine the feature subset based on downstream model performance.
⚠️ Common Interview Pitfalls
- ✕Running filter methods or RFE on the entire dataset prior to cross-validation split, introducing data leakage
- ✕Relying solely on univariate filters, which discard features that are informative only in combination (e.g., XOR problem)
🎯 Interviewer Follow-up Inquiries
- ?Why can univariate filter methods fail completely on features that form an XOR relationship with the target?
- ?What is the computational complexity difference between Recursive Feature Elimination (RFE) and Lasso?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
📚
Associated Knowledge Base Guides & Mindmaps
Explore the comprehensive technical article, exam cards, and global architecture tree.
中文速览与面试要点
比较过滤式、包裹式与嵌入式特征选择
过滤式按统计量排序(快但忽略模型);包裹式按模型性能搜索(准但贵);嵌入式在训练中选(如 L1/树重要度)。
核心要点
- 三类方法的核心差异在于'是否使用模型性能作为准则':① 过滤式(Filter) ——用统计量独立评估每个特征与目标的关系(卡方、互信息、相关系数、方差阈值),排序后取 top-k。优点:极快(O(np))、与模型无关、可并行;缺点: 忽略特征间交互与冗余 (一个单独看很弱的特征可能与另一特征组合后很强;两个高度冗余的特征会被同时保留)。② 包裹式(Wrapper) ——用模型的性能作为评价准则,搜索特征子集。 RFE(递归特征消除) :训练模型 → 删除最不重要的特征 → 重复; 前向/后向选择 :逐个添加/删除。优点:直接优化目标、考虑交互;缺点: 计算极贵 (需训练 O(p) 到 O(2^p) 次模型)、易过拟合(在同一数据上反复评估)。③ 嵌入式(Embedded) ——在模型训练过程中完成选择:L1 正则(LASSO 的稀疏解)、树模型的特征重要度、ElasticNet。优点:计算成本与训练相当、考虑特征交互;缺点:依赖特定模型、选择结果的稳定性有限(如 LASSO 在相关特征上不稳定)。
- 实践选择与要点:① 优先嵌入式 ——性价比最高(一次训练即得),是实践首选;树模型的重要度 + 阈值、或 LASSO/ElasticNet 最常用。② 过滤式用于粗筛 ——当 p 极大(如文本 p=10⁵)时,先用过滤式降到 p'=10³–10⁴,再用嵌入式或包裹式精筛,这是大规模场景的标准流程。③ 包裹式的适用 ——仅当 p 较小( 必须放进 CV ——任何特征选择步骤都必须在 CV 的 训练折内 做,否则会因'用全量数据选特征'而泄漏(选择的特征已经看过验证集的标签),导致性能高估。⑤ 稳定性问题 ——用不同随机种子/子采样重复选择,检查所选特征的稳定性(如用 Jaccard 相似度);不稳定的选择不可靠(常见于强相关特征组)。⑥ 与降维的区别 ——特征选择保留原始特征(可解释),降维生成新特征(PCA 的主成分不可解释);若需可解释性选前者。
- RFE 贪心删除最差特征
- 嵌入式性价比最高
常见陷阱
- 把特征选择放在 CV 之外(数据泄漏)
- 对大规模 p 直接做包裹式搜索