承接 codedheartinside/apriori 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codedheartinside/apriori

Composer 安装命令:

composer require codedheartinside/apriori

包简介

Apriori data analysing algorithm written within PHP.

README 文档

README

Run Unit Tests

This package is meant for implementing the Apriori algorithm as a microservice.

Installation:

Enable composer in your project

curl -s http://getcomposer.org/installer | php

Add the package to your composer.json file

{
    "require": {
        "codedheartinside/apriori": "1.*"
    }
}

Load the files and create the autoload file

Download the files

php composer.phar install

Add the autoloader for the files into your project

require 'vendor/autoload.php';

Set up the running environment

To set up the running environment for the package, run the installer

$installer = new \CodedHeartInside\DataMining\Apriori\Installer();
$installer->createRunningEnvironment();

Usage

Configuration

You first need to create a configuration with the rules for the algorithm

$aprioriConfiguration = new \CodedHeartInside\DataMining\Apriori\Configuration();

// Configuring the boundries is optional
$aprioriConfiguration->setDisplayDebugInformation();
$aprioriConfiguration->setMinimumThreshold(2) // Default is 2
    ->setMinimumSupport(0.2) // Default is 0.1
    ->setMinimumConfidence(5) // Default is 0.2
;

Defining the data set

After that, all is set to run the algorithm on a data set. The data set can be added through the addDataSet function.

$dataSet = array(
    array(1, 3, 4),
    array(2, 4, 6),
    array(1, 2),
    array(5),
);

$dataInput = new \CodedHeartInside\DataMining\Apriori\Data\Input($aprioriConfiguration);
$dataInput->flushDataSet()
    ->addDataSet($dataSet)
    ->addDataSet($dataSet) // In this case, the data set is added twice to create more testing data
;

Running the algorithm

To run the the algorithm on the data set, provide the Apriori class with the configuration and call the run function.

$aprioriClass = new \CodedHeartInside\DataMining\Apriori\Apriori($aprioriConfiguration);
$aprioriClass->run();

Retrieving the data

After running the algorithm, the records with the statistics for support and confidence become retrievable.

Support is the time a item combination occurs in all of the provided item sets.

To get the records with the support statistics:

foreach ($aprioriClass->getSupportRecords() as $record) {
    print_r($record);
    // Outputs:
    // Array
    // (
    //     [itemIds] => Array
    //     (
    //         [0] => 1
    //         [1] => 4
    //         [2] => 6
    //         [3] => 7
    //     )
    //
    //     [support] => 0.060606060606061
    // )
}

Confidence is the times a article occurs in combination with the other items

To get the records with the confidence statistics

foreach ($aprioriClass->getConfidenceRecords() as $record) {
    print_r($record);
    // Outputs
    // Array
    // (
    //     [if] => Array
    //     (
    //       [0] => 1
    //       [1] => 7
    //     )
    //
    //     [then] => 3
    //     [confidence] => 1
    // )
}

codedheartinside/apriori 适用场景与选型建议

codedheartinside/apriori 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.4k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2015 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「data mining」 「apriori」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 codedheartinside/apriori 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codedheartinside/apriori 我们能提供哪些服务?
定制开发 / 二次开发

基于 codedheartinside/apriori 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 22.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-07