# 分类树

分类树是一种监督机器学习方法，它通过基于特征的决策规则对数据进行递归划分，来预测一个类别标签。每个内部节点对一个特征（或在某些变体中，对特征的线性组合）施加一个测试，每条分支承载该测试的一个结果，每个叶节点赋予一个类别。其结果是一组 if-then 规则，将输入划分成轴对齐的矩形区域，每个区域对应一个预测类别。<sup>[1](https://www.mdpi.com/1999-4893/19/1/37)</sup> [分类](https://www.edgepedia.org/zh/classification)树是统计学和数据挖掘中使用最广泛的工具之一，既可作为独立的可解释模型，也可作为集成方法的基础学习器。<sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 输出 | 一棵由特征测试构成的树，每个叶节点赋予一个类别；CART 构建二叉树 <sup>[3](https://www.ise.bgu.ac.il/faculty/liorr/hbchap9.pdf)</sup> |
| 分裂准则 | 基尼指数、熵（信息增益）或误分类率 <sup>[4](https://online.stat.psu.edu/stat508/Lesson12.html)</sup> |
| 分裂选择 | 最大化不纯度下降 \( IG(j,s,t) = I(t) - P_{t_L} I(t_L) - P_{t_R} I(t_R) \) <sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup> |
| 剪枝 | 代价复杂度 \( R_{\alpha}(T) = R(T) + \alpha \cdot |\tilde{T}| \)，其中 \( \alpha \) 通过交叉验证或 1-SE 规则选取 <sup>[4](https://online.stat.psu.edu/stat508/Lesson12.html)</sup> |
| 缺失值 | CART 使用代理分裂；C4.5 以分数权重将样本送入每条分支 <sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup> |
| 精度与集成方法对比 | 最佳单树算法平均比最佳树集成方法低约 10% 的精度 <sup>[6](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)</sup> |
| 集成方法 | 树是 bagging、随机森林和梯度树提升的基础学习器 <sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup> |

## 工作原理

该方法是递归划分。从根节点上的全部训练样本开始，算法搜索候选分裂，施加最佳分裂，并在每个子节点内重复，直到满足某个停止条件。对于一个类别比例为 \( p_1, \dots, p_K \) 的节点，候选的不纯度度量包括基尼指数 \( \sum_{j=1}^{K} p_j \cdot (1-p_j) = 1 - \sum_{j=1}^{K} p_j^2 \)、熵 \( \sum_j p_j \log(1/p_j) \) 以及误分类率 \( 1 - \max_j p_j \)。<sup>[4](https://online.stat.psu.edu/stat508/Lesson12.html)</sup> 一个分裂的质量即其不纯度下降量：对于节点 \( t \) 处的候选分裂 \( (j,s) \)，\( IG(j,s,t) := I(t) - P_{t_L} I(t_L) - P_{t_R} I(t_R) \)，选择使该增益最大化的分裂。<sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup> CART 是最著名的实现，它只构建二叉树，并引入了基尼准则和 twoing 准则。<sup>[7](https://www.odbms.org/wp-content/uploads/2014/07/DecisionTrees.pdf)</sup> 对于一个新的观测，预测沿与其特征值匹配的分支下行至叶节点。

## 实现方法

C4.5 和 CART 在概念上包含两个阶段：生长和剪枝。<sup>[3](https://www.ise.bgu.ac.il/faculty/liorr/hbchap9.pdf)</sup> 生长是贪心的、自顶向下的；对于 CART 和 C4.5 风格的算法，在 \( p \) 个特征和 \( N \) 个样本的情况下，平均情况复杂度为 \( O(p \cdot N \log^2(N)) \)。<sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup> 常见的停止规则包括：节点中所有样本属于同一类别、达到最大深度、节点样本数低于最小值、子节点低于最小规模，或最佳分裂准则低于阈值。<sup>[3](https://www.ise.bgu.ac.il/faculty/liorr/hbchap9.pdf)</sup>

CART 通常生长一棵大树，然后使用代价复杂度剪枝来选取一棵较小的子树，而实际实现也可能在生长过程中施加停止条件。<sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup> 原始 CART 并不提前停止，而是生长一棵大树，将其剪回根节点，并使用交叉验证估计每棵子树的误分类代价，选择代价最低者。<sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup><sup> • </sup><sup>[26](https://search.r-project.org/CRAN/refmans/rpart/html/rpart.control.html)</sup> 代价复杂度度量为 \( R_{\alpha}(T) = R(T) + \alpha \cdot |\tilde{T}| \)，其中 \( |\tilde{T}| \) 是叶节点数，\( \alpha \ge 0 \) 惩罚树的规模；随后 1-SE 规则选择估计误差不超过最佳树的估计误差加一个标准误的最小树。<sup>[4](https://online.stat.psu.edu/stat508/Lesson12.html)</sup> 减少误差剪枝则使用一个单独的验证集。<sup>[3](https://www.ise.bgu.ac.il/faculty/liorr/hbchap9.pdf)</sup>

## 起源

这一思想有两个独立的根源。在统计学中，Morgan 和 Sonquist 在 1963 年《[美国统计协会杂志](https://www.edgepedia.org/zh/journal-of-the-american-statistical-association)》的一篇论文中引入了递归划分方法 AID（自动交互检测）。<sup>[8](https://doi.org/10.1080/01621459.1963.10500855)</sup> Loh 的历史综述称 AID 是文献中发表的第一个回归树算法。<sup>[6](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)</sup> 在机器学习中，Hunt 的概念学习系统框架（Hunt、Marin 和 Stone，1966）是树归纳家族的鼻祖。<sup>[9](https://link.springer.com/content/pdf/10.1007/BF00116251.pdf)</sup>

第一个分类树算法 THAID 于 1970 年代初问世。<sup>[10](https://api.pageplace.de/preview/DT0400.9781351460491_A31471984/preview-9781351460491_A31471984.pdf)</sup><sup> • </sup><sup>[10](https://api.pageplace.de/preview/DT0400.9781351460491_A31471984/preview-9781351460491_A31471984.pdf)</sup> CART 相对于 AID 和 THAID 的新增内容包括：用剪枝代替停止规则、通过交叉验证选择树、不等先验与代价、代理分裂、变量重要性评分，以及通过随机搜索找到的线性组合分裂。<sup>[11](https://washstat.org/presentations/20150604/loh_slides.pdf)</sup> 在机器学习方面，Quinlan 于 1986 年在《Machine Learning》上报告了 ID3，<sup>[9](https://link.springer.com/content/pdf/10.1007/BF00116251.pdf)</sup> 它由 CLS 框架发展而来，在每个节点选择使增益最大的属性。<sup>[9](https://link.springer.com/content/pdf/10.1007/BF00116251.pdf)</sup>

## 变体

**CART** 基于基尼或 twoing 准则进行二叉分裂，支持用户指定的类别先验、不等误分类代价和线性组合分裂，并通过选择与原始分裂预测关联最大的代理分裂来处理缺失值。<sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup> **ID3 及其后裔** 使用熵：C4.5 将分类变量按每个取值分成一条分支，并选择增益比最高的分裂，增益比基于 \( e(t) = -\sum_j p(j|t) \log p(j|t) \)，并能处理 ID3 无法处理的数值属性和缺失值。<sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup> 增益比将增益除以划分的潜在信息量，纠正了普通增益准则偏好具有多结果测试的倾向；C4.5 后来在商业上被 C5.0 取代。<sup>[12](https://ai.stanford.edu/~ronnyk/treesHB.pdf)</sup> **CHAID** 由 G. V. Kass 于 1980 年报告，<sup>[13](https://doi.org/10.2307/2986296)</sup> 是第一种基于列联表统计显著性检验的方法，将变量选择与分裂分离。<sup>[14](https://www.zeileis.org/papers/Hothorn+Hornik+Zeileis-2006.pdf)</sup> **QUEST** 通过在选择分裂点之前对非分类变量使用 ANOVA F 检验、对分类变量使用[卡方检验](https://www.edgepedia.org/zh/chi-squared-test)，避免了 CART 的变量选择偏差；GUIDE 是一个相关的无偏选择程序。<sup>[5](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)</sup> **条件推断树** 由 Hothorn、Hornik 和 Zeileis 于 2006 年报告，<sup>[14](https://www.zeileis.org/papers/Hothorn+Hornik+Zeileis-2006.pdf)</sup> 检验所有协变量与响应之间独立的全局零假设，选择关联最强的协变量，并在零假设无法在水平 \( \alpha \) 下被拒绝时停止，从而通过统计而非算法手段解决过拟合和选择偏差问题。<sup>[14](https://www.zeileis.org/papers/Hothorn+Hornik+Zeileis-2006.pdf)</sup> **斜树** 基于超平面而非单个特征进行分裂：带线性组合的 CART 是第一个斜算法，而 OC1 由 Murthy、Kasif 和 Salzberg 于 1994 年报告，它将确定性爬山法与两种随机化形式相结合以逃离局部极小值。<sup>[15](https://www.jair.org/index.php/jair/article/download/10121/23968/18406)</sup> 近期的一条研究路线寻求可证明最优的稀疏树而非贪心树：OSDT 是一种实用的动态规划和分支定界算法，GOSDT（Lin 及其同事，2020）将其推广到其他目标，DL8.5（Aglin 及其同事，2020）在节点和分支上进行搜索，MurTree（Demirović 及其同事，2022）增加了相似性界。<sup>[16](https://arxiv.org/html/2406.02175v1)</sup>

## 应用

有文献记载的应用集中在医学和流行病学领域。CART 和条件推断树都能识别同质的人群亚组，并在亚组存在时改进相对于回归的预测；条件推断树中的正式假设检验简化了解释。<sup>[17](https://link.springer.com/article/10.1186/s12982-017-0064-4)</sup> 在 Box Lunch 研究中，一棵预测总能量摄入的条件推断树揭示了有意义的亚组，例如零食热量在 798.22 及以下与以上的对比，\( p < 0.001 \)。<sup>[17](https://link.springer.com/article/10.1186/s12982-017-0064-4)</sup> 除了直接建模，树还作为基础学习器：bagging、随机森林和梯度树提升都建立在决策树之上。<sup>[2](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)</sup> Bagging（Breiman，1996）、<sup>[18](https://doi.org/10.1023/a:1018054314350)</sup> 随机森林（Breiman，2001）<sup>[19](https://doi.org/10.1023/a:1010933404324)</sup> 和梯度树提升都会生长许多树：随机森林在自助样本上生长未剪枝的 CART 树，并通过在每个节点抽取随机变量子集来削弱它们之间的依赖性。<sup>[20](https://www.eecis.udel.edu/~shatkay/Course/papers/RandomForestGentleIntro2009.pdf)</sup> XGBoost 由 Chen 和 Guestrin 于 2016 年报告，<sup>[21](https://doi.org/10.48550/arxiv.1603.02754)</sup> 是梯度提升的一种实现，被广泛认为是表格数据的首选方法。<sup>[22](https://www.frontiersin.org/journals/artificial-intelligence/articles/10.3389/frai.2023.1124553/pdf)</sup>

## 局限与替代方案

**过拟合。** 再代入误差率 \( R(T) \) 存在向下偏差，因此最小化它总是偏好更大的树，无法防止过拟合；需要剪枝或诚实的误差估计。<sup>[4](https://online.stat.psu.edu/stat508/Lesson12.html)</sup> 随着树变得更深，每个节点的样本变得稀疏，分裂选择变得更加多变，不纯度准则偏向多数类。<sup>[1](https://www.mdpi.com/1999-4893/19/1/37)</sup>

**不稳定性。** 学习数据的微小变化可能改变第一个分裂变量或切分点，从而改变整棵树，因此单树预测表现出高变异性。<sup>[20](https://www.eecis.udel.edu/~shatkay/Course/papers/RandomForestGentleIntro2009.pdf)</sup> CART 长期以来有不够稳定的名声，bagging、提升和随机森林正是为了通过组合子模型来稳定树预测器而开发的，代价是可解释性。<sup>[23](https://jmlr.org/papers/volume23/20-667/20-667.pdf)</sup>

**选择偏差。** 一个有 \( n \) 个不同取值的有序变量提供 \( n-1 \) 个候选分裂，而一个有 \( m \) 个取值的分类变量提供 \( 2^{m-1}-1 \) 个，这使穷举搜索算法偏向具有更多分裂点的变量。<sup>[6](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)</sup> CART 也偏向具有更多缺失值的分裂变量，以及具有更少缺失值的代理变量，因为基尼指数依赖于类别比例而非类别样本量。<sup>[6](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)</sup> 基于不纯度的分裂偏向多数类，因此在类别不平衡下，除非使用类别权重、平衡子采样或调整阈值，少数类会被系统性地漏检。<sup>[1](https://www.mdpi.com/1999-4893/19/1/37)</sup> 找到完美拟合数据集的最小树是 NP 难的。<sup>[22](https://www.frontiersin.org/journals/artificial-intelligence/articles/10.3389/frai.2023.1124553/pdf)</sup>

**相对于替代方案的精度。** 在一项对 32 个数据集上 33 种算法的比较中，基于样条的 POLYCLASS 在平均误差率上排名第一，逻辑回归排名第二；最准确的树是带线性分裂的 QUEST，排名第四和第五。<sup>[24](https://link.springer.com/content/pdf/10.1023/A:1007608224229.pdf)</sup> 在单变量分裂树中，C4.5、IND-CART 和 QUEST 具有最佳的误差率与速度组合，但 C4.5 产生的叶节点数约为 IND-CART 和 QUEST 的两倍。<sup>[24](https://link.springer.com/content/pdf/10.1023/A:1007608224229.pdf)</sup> 当透明的规则集、快速评分或逐叶解释比与最佳集成方法之间约 10% 的平均精度差距更重要时，单棵树是首选。<sup>[6](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)</sup> 最优稀疏树方法瞄准可解释单树的细分领域；梯度提升集成仍然是表格数据上的精度领先者，在已发表的比较中甚至击败了深度神经网络。<sup>[25](https://arxiv.org/html/2405.15911v2)</sup>

## References

1. [A Survey of Six Classical Classifiers (Algorithms, 2026, MDPI)](https://www.mdpi.com/1999-4893/19/1/37)
2. [Large Scale Prediction with Decision Trees (Klusowski, Annals of Statistics)](https://klusowski.princeton.edu/sites/g/files/toruqf5901/files/documents/klusowski2024large.pdf)
3. [Decision Trees (Rokach & Maimon, Data Mining and Knowledge Discovery Handbook, ch. 9)](https://www.ise.bgu.ac.il/faculty/liorr/hbchap9.pdf)
4. [Tree-based Methods – STAT 508 (Penn State)](https://online.stat.psu.edu/stat508/Lesson12.html)
5. [Classification and Regression Tree Methods (Loh, Encyclopedia of Statistics in Quality and Reliability)](https://pages.stat.wisc.edu/~loh/treeprogs/guide/eqr.pdf)
6. [Fifty Years of Classification and Regression Trees (Loh, ISI, 2014)](https://pages.stat.wisc.edu/~loh/treeprogs/guide/LohISI14.pdf)
7. [Decision Tree Discovery chapter (Data Classification: Algorithms and Applications)](https://www.odbms.org/wp-content/uploads/2014/07/DecisionTrees.pdf)
8. [James N. Morgan, John A. Sonquist (1963). Problems in the Analysis of Survey Data, and a Proposal. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1963.10500855)
9. [Induction of decision trees (Quinlan, Machine Learning, 1986)](https://link.springer.com/content/pdf/10.1007/BF00116251.pdf)
10. [Classification and Regression Trees (Breiman, Friedman, Olshen, Stone, 1984), publisher preview](https://api.pageplace.de/preview/DT0400.9781351460491_A31471984/preview-9781351460491_A31471984.pdf)
11. [A Brief History of Classification and Regression Trees (Loh slides, 2015)](https://washstat.org/presentations/20150604/loh_slides.pdf)
12. [C5.1.3 Decision Tree Discovery (Kerber/Chickering handbook chapter)](https://ai.stanford.edu/~ronnyk/treesHB.pdf)
13. [G. V. Kass (1980). An Exploratory Technique for Investigating Large Quantities of Categorical Data. Journal of the Royal Statistical Society Series C (Applied Statistics).](https://doi.org/10.2307/2986296)
14. [Unbiased Recursive Partitioning: A Conditional Inference Framework (Hothorn, Hornik & Zeileis, 2006)](https://www.zeileis.org/papers/Hothorn+Hornik+Zeileis-2006.pdf)
15. [A System for Induction of Oblique Decision Trees (Murthy, Kasif & Salzberg), JAIR](https://www.jair.org/index.php/jair/article/download/10121/23968/18406)
16. [Branches: A Fast Dynamic Programming and Branch & Bound Algorithm for Optimal Decision Trees (arXiv)](https://arxiv.org/html/2406.02175v1)
17. [Decision trees in epidemiological research (BMC)](https://link.springer.com/article/10.1186/s12982-017-0064-4)
18. [Leo Breiman (1996). Bagging Predictors. Machine Learning.](https://doi.org/10.1023/a:1018054314350)
19. [Leo Breiman (2001). Random Forests. Machine Learning.](https://doi.org/10.1023/a:1010933404324)
20. [An Introduction to Recursive Partitioning (Strobl, Malley & Tutz, 2009, Statistical Science)](https://www.eecis.udel.edu/~shatkay/Course/papers/RandomForestGentleIntro2009.pdf)
21. [Chen, Tianqi, Guestrin, Carlos (2016). XGBoost: A Scalable Tree Boosting System. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1603.02754)
22. [Decision trees: from efficient prediction to responsible AI (Costa & Pedreira, 2023, Frontiers in AI)](https://www.frontiersin.org/journals/artificial-intelligence/articles/10.3389/frai.2023.1124553/pdf)
23. [Stable Classification (Bertsimas, Paskov et al., JMLR 2023)](https://jmlr.org/papers/volume23/20-667/20-667.pdf)
24. [A Comparison of Prediction Accuracy, Complexity, and Training Time of Thirty-Three Old and New Classification Algorithms (Lim, Loh & Shih, 2000, Machine Learning)](https://link.springer.com/content/pdf/10.1023/A:1007608224229.pdf)
25. [Learning accurate and interpretable tree-based models (2024, arXiv)](https://arxiv.org/html/2405.15911v2)
26. [Rpart.control (search.r-project.org)](https://search.r-project.org/CRAN/refmans/rpart/html/rpart.control.html)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning › Classification algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/classification-tree

English original: https://www.edgepedia.org/classification-tree
