← Back to Classic ML Mind Map
📊 Classic MLID: decision-trees

Decision Tree Splitting

决策树 CART 分裂
🎯Core Definition
A decision tree recursively partitions the input space with (feature, threshold) splits; the splitting criterion measures split quality. Entropy: H(D)=−∑k=1Kpklog⁡2pkH(D) = -\sum_{k=1}^{K} p_k \log_2 p_k; Gini impurity: G(D)=1−∑k=1Kpk2G(D) = 1 - \sum_{k=1}^{K} p_k^2, which reduces to G=2p(1−p)G = 2p(1-p) in binary classification (max 0.5 at p=0.5p = 0.5). The CART classifier greedily picks the feature AA and split point vv maximizing the Gini decrease ΔG(A,v)=G(D)−∣DL∣∣D∣G(DL)−∣DR∣∣D∣G(DR)\Delta G(A, v) = G(D) - \frac{|D_L|}{|D|} G(D_L) - \frac{|D_R|}{|D|} G(D_R), where DL={x∣xA≤v}D_L = \{ x \mid x_A \leq v \} and DR=D∖DLD_R = D \setminus D_L. ID3 uses information gain Gain(D,A)=H(D)−∑v=1V∣Dv∣∣D∣H(Dv)\text{Gain}(D, A) = H(D) - \sum_{v=1}^{V} \frac{|D_v|}{|D|} H(D_v), which favors many-valued features (finer partitions lower H(Dv)H(D_v)); C4.5 uses the gain ratio Gain_ratio(D,A)=Gain(D,A)IV(A)\text{Gain\_ratio}(D, A) = \frac{\text{Gain}(D, A)}{\text{IV}(A)} with intrinsic value IV(A)=−∑v=1V∣Dv∣∣D∣log⁡2∣Dv∣∣D∣\text{IV}(A) = -\sum_{v=1}^{V} \frac{|D_v|}{|D|} \log_2 \frac{|D_v|}{|D|} to penalize the number of values; CART is always binary (one threshold per split), using Gini for classification and variance reduction err(D)=1∣D∣∑i∈D(yi−yˉD)2\text{err}(D) = \frac{1}{|D|} \sum_{i \in D} \left(y_i - \bar{y}_D\right)^2 for regression. Continuous features: after sorting, only midpoints x(i)+x(i+1)2\frac{x^{(i)} + x^{(i+1)}}{2} of adjacent samples are candidate split points (any threshold is equivalent to the midpoint of the cell it falls into), at most n−1n-1 candidates, O(nlog⁡n)O(n \log n) per feature.
💡Use Cases
classic interview trio — differences among ID3 / C4.5 / CART criteria, why information gain prefers many-valued features, and how continuous features are split; it is also the starting point for deriving RF (Gini) and XGBoost/LightGBM (structural gain) splitting.
⚡Key Problems Solved
it turns the exponential search over (feature, threshold) combinations (optimal decision trees are NP-hard) into one greedy linear scan per node — each candidate split costs O(n)O(n), so a node costs O(d⋅nlog⁡n)O(d \cdot n \log n); greedy splitting is not globally optimal but is good enough in practice with pruning and randomization, and the criteria depend only on class proportions/variance, so they are scale-free and handle nonlinearity natively.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Decision Tree Splitting.
Use Cases
In production engineering, what are the primary use cases for Decision Tree Splitting and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Whiteboard Gini impurity G=1−∑kpk2G = 1 - \sum_k p_k^2: why does it reduce to 2p(1−p)2p(1-p) for binary classes? Pros and cons vs entropy?
2
Write information gain and explain its bias toward many-valued features; how does the gain ratio fix it with the intrinsic value IV(A)\text{IV}(A)?
3
What splitting criteria do ID3 / C4.5 / CART use? Why must CART be a binary tree?
4
How are continuous features split? Why only midpoints of adjacent sorted values? What is the per-feature complexity?
5
What are the splitting criterion and leaf output of a CART regression tree? Why is the leaf output the mean yˉ\bar{y}?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Decision Tree Splitting"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardKernel Trick & RBFNext Card →Tree Pruning

🔗 More Classic ML Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/ML/card/decision-trees
中文速览与面试要点

决策树 CART 分裂 (Decision Tree Splitting)

定义: 决策树是递归二分特征的判别模型, 每个节点用“特征 + 切分点”把样本分成左右两支, 分裂准则决定切分质量。熵: H(D) = - _k=1^K p_k _2 p_k; Gini 不纯度: G(D) = 1 - _k=1^K p_k^2, 二分类退化为 G = 2p(1-p)(类 1 概率 p, p = 0.5 时最大 0.5)。CART 分类树贪心搜索特征 A 与切分点 v, 使分裂前后 Gini 下降最大: G(A, v) = G(D) - |D_L||D| G(D_L) - |D_R||D| G(D_R), 其中 D_L = \ x x_A v \, D_R = D D_L。ID3 用信息增益 Gain(D, A) = H(D) - _v=1^V |D_v||D| H(D_v), 它天然偏好取值多的特征 (划分越细 H(D_v) 越小); C4.5 用增益比 Gain\_ratio(D, A) = Gain(D, A) IV(A), 其中固有值 IV(A) = - _v=1^V |D_v||D| _2 |D_v||D| 惩罚特征取值个数; CART 恒为二叉树 (每次只做一个二值切分), 分类用 Gini、回归用方差下降 err(D) = 1|D| _i D (y_i - y_D )^2。连续特征: 按特征值排序后只检查相邻样本的中点 x^(i) + x^(i+1)2 作为候选切分点 (任意区间内切分效果只由落在哪两个相邻点之间决定), 候选点最多 n-1 个, 单特征排序 O(n n)。 使用场景: 面试必考的算法三连问 — “ID3 / C4.5 / CART 分裂准则区别”“为什么信息增益偏好取值多的特征”“连续特征怎么切”; 也是随机森林 (Gini 分裂)、XGBoost/LightGBM (结构增益/方差) 分裂逻辑的推导起点。 解决的问题: 把“选哪个特征、在哪切”的指数级搜索 (最优决策树问题是 NP 难) 化为每步贪心的一次线性扫描 — 每个候选切分只需 O(n) 算一次不纯度, 单节点复杂度 O(d n n); 贪心不保证全局最优, 但配合剪枝与随机化 (随机森林) 在实践里足够好, 且分裂准则只依赖类别比例/方差, 对特征尺度不敏感、天然处理非线性。

核心要点

  • 白板推导 Gini 不纯度 G = 1 - _k p_k^2: 二分类为什么退化为 2p(1-p)? 与熵 H = - _k p_k p_k 相比有何优缺点?
  • 写出信息增益 Gain(D, A) = H(D) - _v |D_v||D| H(D_v) 并解释为什么它偏好取值多的特征; 增益比如何用固有值 IV(A) 修正?
  • ID3 / C4.5 / CART 的分裂准则分别是什么? 为什么 CART 一定是二叉树?
  • 连续特征如何切分? 为什么只用相邻样本中点 x^(i) + x^(i+1)2 作候选切分点? 单特征的时间复杂度是多少?
  • CART 回归树的分裂准则与叶子输出是什么? 为什么叶子输出是均值 y?