# FP-Growth

**FP-Growth**（频繁模式增长）是一种从事务数据库中挖掘频繁项集的算法，它将数据库压缩为一种称为FP树的前缀树结构，并从中提取模式，而不生成候选集。该算法由西蒙弗雷泽大学的韩家炜（Jiawei Han）、裴健（Jian Pei）和尹一文（Yiwen Yin）在2000年SIGMOD论文《不生成候选集的频繁模式挖掘》中提出，其中“FP”代表频繁模式（frequent pattern）。<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 韩家炜、裴健和尹一文，SIGMOD 2000，DOI 10.1145/335191.335372<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup> |
| 核心结构 | FP树，一种扩展前缀树，存储关于频繁模式的压缩信息<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup> |
| 候选集生成 | 无；模式从模式片段生长而来，而非针对候选集进行测试<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup> |
| 数据库扫描 | 两次扫描数据库，而逐层方法需要反复扫描<sup>[2](https://link.springer.com/article/10.1007/s40747-020-00226-4)</sup> |
| 报告速度 | 在原始性能研究中比Apriori算法快约一个数量级<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup> |
| 主要局限 | 内存：对于非常大或稀疏的数据集，FP树可能无法装入主存<sup>[2](https://link.springer.com/article/10.1007/s40747-020-00226-4)</sup> |
| 并行形式 | PFP（并行FP-Growth），李浩源等，RecSys 2008；在包含802,939个网页和1,021,107个标签的数据集上实现近线性加速<sup>[3](https://research.google.com/pubs/archive/34668.pdf)</sup> |

## 所解决的问题

挖掘频繁项集——即在事务中共同出现的频率超过最小支持度阈值的项集——是关联规则分析的第一步。在FP-Growth之前，大多数研究采用类似Apriori的候选集生成与测试方法：一次扫描找到频繁1项集，由此构建候选2项集，逐层重复该过程，直到不再出现新的频繁项集。候选集的生成代价仍然高昂，尤其是当存在大量模式或长模式时。<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup>

## 算法工作原理

**压缩为FP树。** 第一步计算项频率并识别频繁项。然后将数据库压缩为FP树——一种扩展前缀树，其中共享项的事务共享树路径，因此公共前缀只存储一次。这种压缩结构避免了昂贵且重复的数据库扫描。<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup><sup> • </sup><sup>[4](https://spark.apache.org/docs/preview/mllib-frequent-pattern-mining.html)</sup>

**模式生长。** 挖掘在树上递归进行。对于每个项，算法构建其条件模式基——即FP树中以该项结尾的前缀路径集合——然后从该基构建条件FP树；每棵条件FP树都有自己的头表，根据该树自身的模式基重新计数。<sup>[5](https://web.cs.ucla.edu/~yzsun/classes/2013Spring_CS6220/slides/06FPBasic.pdf)</sup><sup> • </sup><sup>[6](https://dsapanicle.com/fundamentals/machine-intelligence/unsupervised-learning/fp-growth/)</sup> 当树只包含单条路径时过程停止，此时路径上节点的每种组合都作为模式输出，其支持度等于该组合中节点的最小支持度；或者当树为空时停止。<sup>[5](https://web.cs.ucla.edu/~yzsun/classes/2013Spring_CS6220/slides/06FPBasic.pdf)</sup>

原始论文将该方法的效率归因于三项技术：将大型数据库压缩为小得多的结构；模式片段生长方法，避免生成大量候选集；以及将挖掘任务划分、分治分解为条件数据库上的更小任务，从而缩小搜索空间。<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup>

## 性能与比较

原始性能研究发现，FP-growth在挖掘长频繁模式和短频繁模式时都高效且可扩展，比Apriori快约一个数量级。<sup>[1](https://cir.nii.ac.jp/crid/1360574094442900352)</sup> 一项在稠密数据集（Zoo、Lymph、Mushroom）和稀疏数据集（Retail、T10I4D100K、T40I10D100K）上进行的比较实证研究发现，FP-Growth在所有三个稠密数据集上在执行时间和内存使用方面都是最佳的频繁项集算法，这些数据集中频繁项重叠且FP树压缩效果好。<sup>[2](https://link.springer.com/article/10.1007/s40747-020-00226-4)</sup>

同一研究也指出了该算法的弱点。在稀疏数据上，频繁项之间的节点共享减少，FP树变得庞大而茂密，内存使用和执行时间受到影响；H-Mine将项存储在由超链接连接的队列中而非树中，在所有三个稀疏数据集上表现最佳。<sup>[2](https://link.springer.com/article/10.1007/s40747-020-00226-4)</sup> 对于非常大的数据集，FP树可能无法装入主存，此时可以使用可扩展的变体。<sup>[2](https://link.springer.com/article/10.1007/s40747-020-00226-4)</sup> 另一项关于数据集特征的研究发现，Eclat和FP-Growth在处理最大事务大小和频繁项集密度的增加方面都明显优于Apriori。<sup>[7](https://arxiv.org/abs/1701.09042)</sup>

## 并行与分布式实现

当数据集巨大时，单机FP树成为瓶颈，因为内存使用和计算成本都在增长。PFP（并行FP-Growth）由Google北京研究院的李浩源（Haoyuan Li）及其同事开发，在RecSys 2008上展示，它将计算分区，使每台机器基于事务后缀执行一组独立的挖掘任务，消除了机器之间的计算依赖和通信。在包含802,939个网页和1,021,107个标签的数据集上，PFP实现了近乎线性的加速，作者将其应用于搜索引擎的查询推荐。<sup>[3](https://research.google.com/pubs/archive/34668.pdf)</sup>

[Apache Spark](https://www.edgepedia.org/zh/apache-spark)的`spark.mllib`实现了这一并行版本。其`FPGrowth`接收一个事务RDD和两个主要参数：`minSupport`，即项集被视为频繁的最小支持度（一个项在5个事务中出现3次，其支持度为3/5 = 0.6）；以及`numPartitions`，即用于分配工作的分区数。默认构造函数使用`minSupport`为0.3，分区数等于输入数据的分区数。返回的模型存储频繁项集及其频率，并可以按选定的最小置信度生成关联规则。<sup>[4](https://spark.apache.org/docs/preview/mllib-frequent-pattern-mining.html)</sup><sup> • </sup><sup>[8](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/mllib/fpm/FPGrowth.html)</sup>

## 应用

使用FP-Growth进行频繁项集挖掘被用于购物篮分析和推荐，包括搜索引擎的查询推荐。<sup>[3](https://research.google.com/pubs/archive/34668.pdf)</sup> 在健康信息学中，一个名为PNFP-Growth的扩展框架基于FP-Growth构建，从体检数据中挖掘正关联规则和负关联规则，因为基础算法只处理正模式；对真实体检记录的分析发现，例如超过30%的高血压患者同时存在收缩压偏高和肝脏问题。<sup>[9](https://scholars.hkbu.edu.hk/en/publications/comprehensive-association-rules-mining-of-health-examination-data/)</sup> [MapReduce](https://www.edgepedia.org/zh/mapreduce)平台的比较研究已在Hadoop、Spark和Flink上对不同数据集规模评估了FP-Growth与Apriori。<sup>[10](https://arxiv.org/abs/1902.10999)</sup>

## References

1. [Han, Jiawei; Pei, Jian; Yin, Yiwen (2000). Mining frequent patterns without candidate generation. ACM SIGMOD Record 29(2), 1–12.](https://cir.nii.ac.jp/crid/1360574094442900352)
2. [Comparative evaluation of pattern mining techniques: an empirical study. Complex & Intelligent Systems (2021).](https://link.springer.com/article/10.1007/s40747-020-00226-4)
3. [Li, Haoyuan; Wang, Yi; Zhang, Dong; Chang, Edward; Zhang, Ming (2008). PFP: Parallel FP-Growth for Query Recommendation. RecSys 2008.](https://research.google.com/pubs/archive/34668.pdf)
4. [Frequent Pattern Mining – RDD-based API, Spark documentation](https://spark.apache.org/docs/preview/mllib-frequent-pattern-mining.html)
5. [FP-Growth Algorithm Sketch, lecture slides, UCLA CS6220](https://web.cs.ucla.edu/~yzsun/classes/2013Spring_CS6220/slides/06FPBasic.pdf)
6. [FP-Growth Algorithm, DSA Panicle](https://dsapanicle.com/fundamentals/machine-intelligence/unsupervised-learning/fp-growth/)
7. [Heaton, Jeff (2017). Comparing Dataset Characteristics that Favor the Apriori, Eclat or FP-Growth Frequent Itemset Mining Algorithms. arXiv:1701.09042.](https://arxiv.org/abs/1701.09042)
8. [org.apache.spark.mllib.fpm.FPGrowth, Spark ScalaDoc](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/mllib/fpm/FPGrowth.html)
9. [Wang, Bowei; et al. (2017). Comprehensive Association Rules Mining of Health Examination Data with an Extended FP-Growth Method. Mobile Networks and Applications 22(2), 267–274.](https://scholars.hkbu.edu.hk/en/publications/comprehensive-association-rules-mining-of-health-examination-data/)
10. [Ranjan, Ravi; Sharma, Aditi (2019). Evaluation of Frequent Itemset Mining Platforms using Apriori and FP-Growth Algorithm. arXiv:1902.10999.](https://arxiv.org/abs/1902.10999)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Data mining, warehousing, and big data › Data mining algorithms

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/fp-growth

English original: https://www.edgepedia.org/fp-growth
