M2-091M2: Classical Machine LearningFeature SelectionHard
⚡Flashcard Drill➔Mastery:
Evaluating Feature Importance in Neural Networks vs Tree Models
🎯 Active Recall Self-Check (Draft First, Verify After)
Login-free practice tracker: recall core answer, audit pitfalls, and log review status.
Step 1 · Draft your concise answer & assumptions
Step 2 · Check Pitfalls & Follow-up Inquiries
📐 Mathematical Definition
⚡ One-Sentence Core Answer
Neural networks utilize gradient-based attribution (Integrated Gradients, Saliency) and perturbation methods, whereas tree models rely on impurity gain, split count, and TreeSHAP.
📌 Key Takeaways
- •Gradient methods: Integrated Gradients guarantees completeness and implementation invariance
- •Permutation importance: model-agnostic, shuffles features to observe validation score drops
- •TreeSHAP: polynomial-time exact Shapley calculation for trees () vs path-integral approximation for neural networks
📐 Mathematical Derivations
Methodologies across paradigms:
① Integrated Gradients (IG): Addresses gradient saturation (e.g., in sigmoids or ReLUs) by integrating gradients along the straight-line path from a baseline to input : . In practice, approximated via Riemann sum: . IG satisfies Completeness: .
② Tree-based Methods: Impurity gain (sum of Gini/variance reduction across splits) and split count. Susceptible to bias favoring high-cardinality features. TreeSHAP solves this by computing exact Shapley values recursively down decision paths.
① Integrated Gradients (IG): Addresses gradient saturation (e.g., in sigmoids or ReLUs) by integrating gradients along the straight-line path from a baseline to input : . In practice, approximated via Riemann sum: . IG satisfies Completeness: .
② Tree-based Methods: Impurity gain (sum of Gini/variance reduction across splits) and split count. Susceptible to bias favoring high-cardinality features. TreeSHAP solves this by computing exact Shapley values recursively down decision paths.
🏭 Production Trade-offs
Industrial trade-offs: GBDT feature attribution via TreeSHAP is fast and exact. For deep networks, Integrated Gradients requires 50–100 backward passes per sample, imposing significant computational latency during online explanation serving.
⚠️ Common Interview Pitfalls
- ✕Using simple raw gradients at the input, which suffer from severe gradient saturation in saturated activation regimes
- ✕Choosing an arbitrary or unrepresentative baseline in Integrated Gradients, which distorts attribution results
🎯 Interviewer Follow-up Inquiries
- ?Why does Integrated Gradients satisfy the Implementation Invariance axiom while simple gradient input does not?
- ?What computational advantage does TreeSHAP have over KernelSHAP for tree ensembles?
⚡
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
中文速览与面试要点
在神经网络中如何评估特征重要性?与树模型的方法有何不同?
用梯度/输入×梯度、置换、消融、或注意力/门控;比树模型更贵且更不稳定,需多种子重复。
核心要点
- 神经网络的特征重要度有四类方法:① 梯度类 ——计算 ∂f/∂xᵢ(显著性图 / Saliency),或 Integrated Gradients(IG) (沿从基线到输入的路径积分梯度,满足完备性公理:各特征归因之和 = f(x)−f(baseline));优点是快(一次反向);缺点是 局部 (只在当前点有效)、在 饱和区梯度为 0 (ReLU/sigmoid 饱和时误判为不重要)、且对噪声敏感。② 输入×梯度(Gradient×Input) ——缓解纯梯度的尺度问题(考虑特征值大小),是 DeepLIFT/IG 的简化版。③ 置换重要度 ——在验证集上打乱某特征,看性能下降(模型无关、通用,但需 O(p) 次前向,且相关特征下被稀释)。④ 消融(Ablation) ——把特征置零/置均值后重测,最严谨但最贵。⑤ 结构类方法 —— 注意力权重 (Transformer 中常用,但研究表明注意力权重与重要度 相关性弱 ,不能直接当解释)、 门控机制 (软特征选择层)、 输入层 L1 正则 (促使权重稀疏)。
- 与树模型的差异与实践要点:① 稳定性 ——树模型的重要度是确定性的(给定训练数据);神经网络的重要度依赖初始化、训练随机性与解释方法的超参, 必须多种子重复并报告方差 ,单次结果不可信。② 局部 vs 全局 ——梯度类方法是 局部 解释(针对单个样本),需聚合多个样本才能得到全局重要度;树模型的重要度天然是全局的。③ 相关特征的稀释 ——与树模型一样,神经网络的重要度也受相关特征稀释影响;应配合分组置换或 SHAP(DeepSHAP/GradientSHAP 是神经网络版的 SHAP)。④ 注意力权重的陷阱 ——Jain & Wallace (2019) 等研究表明注意力权重与特征重要度的相关性可能很弱,不能直接作为解释;若要用注意力做解释需专门验证(如与消融结果对比)。⑤ 实践建议 ——需要可靠解释时优先 置换重要度 + 消融 (模型无关、易理解),再配合 SHAP 做逐样本分析;梯度类方法适合快速探索与调试。⑥ 深度学习中的特征选择 ——常用输入层 L1/组 Lasso 或门控网络实现软选择;也可先训练大模型用置换重要度筛选,再用筛后特征训小模型。
- 梯度类方法局部、易受饱和影响
- 置换与消融是模型无关的通用方法
常见陷阱
- 把注意力权重直接当作特征重要度
- 单次运行就下结论(神经网络重要度方差大)