predictator/关联规则

1.2.0 2017-02-11 20:09 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:23:06 UTC


README

使用方法

$assoc = new AssociationRule();

$product1 = new AssociationRule\Product(10);
$product2 = new AssociationRule\Product(11);
$product3 = new AssociationRule\Product(12);

$order1 = new AssociationRule\Order(1);
$order1->addOrderItem($product1);
$order1->addOrderItem($product2);
$assoc->addOrder($order1);

$order2 = new AssociationRule\Order(2);
$order2->addOrderItem($product1);
$assoc->addOrder($order2);

$order3 = new AssociationRule\Order(3);
$order3->addOrderItem($product2);
$order3->addOrderItem($product3);
$assoc->addOrder($order3);

$result = $assoc->getResult(new AssociationRule\Product(10));

导出模型

您可以导出模型以实现高效的响应。模型消耗更少的内存,并且响应速度更快。

$model = $assoc->exportModel(new AssociationRule\AssociationModel());
$result = $model->getResult(new AssociationRule\Product(10));

处理结果

/** @var AssociationRule\Result $item */
foreach ($result as $item) {
	$item->getAssociationPercent(); 
	$item->getId();
	$item->getProduct();
}

测试

Build Status Scrutinizer Code Quality Code Coverage

predictator.eu