enzomc/php-fpgrowth
Composer 安装命令:
composer require enzomc/php-fpgrowth
包简介
PHP implementation of the Frequent Pattern Growth algorithm
README 文档
README
A PHP implementation of the Frequent Pattern Growth algorithm
Getting Started
You can install the package with composer:
composer require enzomc/php-fpgrowth
Usage
Run algorithm
use EnzoMC\PhpFPGrowth\FPGrowth;
$support = 3;
$confidence = 0.7;
$fpgrowth = new FPGrowth($support, $confidence);
$transactions = [
['M', 'O', 'N', 'K', 'E', 'Y'],
['D', 'O', 'N', 'K', 'E', 'Y'],
['M', 'A', 'K', 'E'],
['M', 'U', 'C', 'K', 'Y'],
['C', 'O', 'O', 'K', 'I', 'E']
];
$fpgrowth->run($transactions);
$patterns = $fpgrowth->getPatterns();
$rules = $fpgrowth->getRules();
Returned results
Patterns returns as array of arrays like:
[
['ITEM_1,ITEM_2' => 3],
['ITEM_3' => 5],
...
]
Where key is itemset, value is support of that itemset
Rules returns as array of arrays like:
[
['ITEM_1,ITEM_2', 'ITEM_3', 0.7],
['ITEM_4','ITEM_5', 0.7],
...
]
Where first value is left path of that rule, second value is right path of that rule and third value is confidence of that rule
Result with example transactions
var_dump($patterns);
array(10) {
["M"]=>
int(3)
["K,M"]=>
int(3)
["Y"]=>
int(3)
["K,Y"]=>
int(3)
["E,O"]=>
int(4)
["E,K"]=>
int(4)
["E,K,O"]=>
int(4)
["O"]=>
int(4)
["K,O"]=>
int(4)
["K"]=>
int(5)
}
var_dump($rules);
array(11) {
[0]=>
array(3) {
[0]=>
string(1) "M"
[1]=>
string(1) "K"
[2]=>
float(1)
}
[1]=>
array(3) {
[0]=>
string(1) "Y"
[1]=>
string(1) "K"
[2]=>
float(1)
}
[2]=>
array(3) {
[0]=>
string(1) "O"
[1]=>
string(1) "E"
[2]=>
float(1)
}
[3]=>
array(3) {
[0]=>
string(1) "K"
[1]=>
string(1) "E"
[2]=>
float(0.8)
}
[4]=>
array(3) {
[0]=>
string(1) "K"
[1]=>
string(3) "E,O"
[2]=>
float(0.8)
}
[5]=>
array(3) {
[0]=>
string(1) "O"
[1]=>
string(3) "E,K"
[2]=>
float(1)
}
[6]=>
array(3) {
[0]=>
string(3) "E,K"
[1]=>
string(1) "O"
[2]=>
float(1)
}
[7]=>
array(3) {
[0]=>
string(3) "E,O"
[1]=>
string(1) "K"
[2]=>
float(1)
}
[8]=>
array(3) {
[0]=>
string(3) "K,O"
[1]=>
string(1) "E"
[2]=>
float(1)
}
[9]=>
array(3) {
[0]=>
string(1) "K"
[1]=>
string(1) "O"
[2]=>
float(0.8)
}
[10]=>
array(3) {
[0]=>
string(1) "O"
[1]=>
string(1) "K"
[2]=>
float(1)
}
}
enzomc/php-fpgrowth 适用场景与选型建议
enzomc/php-fpgrowth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.68k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 enzomc/php-fpgrowth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 enzomc/php-fpgrowth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-06-17