fanboykun / datamining
PHP中的数据挖掘计算
dev-main
2023-08-23 12:00 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: *
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-23 14:18:33 UTC
README
本包提供数据挖掘算法的计算,当前可用的算法有KMeans,C45正在开发中。
安装
您可以通过composer安装此包
composer require fanboykun/datamining
使用方法
使用类
use Fanboykun\Datamining\Datamining
在这个例子中,我们将使用KMeans
提供数据示例
$points = Study::all()->map(function ($study, $k) { return [ 'key' => $study->student_id, 'val' => [ $study->matematika, $study->fisika, $study->kimia, $study->biologi, $study->sejarah, $study->akuntansi, $study->sosiologi, $study->geografi, ], ]; })->toArray();
使用一个可用的方法,初始化构造函数
// example, we use KMeans, init with desired space (data example above) $space = (new Datamining)->initKMeans(8)
将所有点添加到空间中
// give the array of the data as the point to insert into space as the first parameter // give the key of the points(data to calculate) as the second parameter // give to value of the data to calculate as the third parameter $space->addAllPointToSpace($points, 'key', 'val');
执行计算
// the required arguments are : // the number of the cluster you want to set // int $numberOfCluster // the initialization method (set to 3 for set the first centroid manually) // $initMethod = 1 // give the index of the array of the points you want set as the first centroid // $selectedPoints = [] $dataset = $space->solveWithIterationCallback(2, 3, [0,1]);
变更日志
请查看 CHANGELOG 了解最近更改的更多信息。
贡献
请查看 CONTRIBUTING 了解详情。
安全
如果您发现任何安全问题,请通过电子邮件 irfanramadhan1812@gmail.com 联系,而不是使用问题跟踪器。
致谢
许可证
MIT许可证(MIT)。请参阅 许可证文件 了解更多信息