predictator/association-rule

1.2.0 2017-02-11 20:09 UTC

This package is not auto-updated.

Last update: 2024-10-27 02:49:20 UTC


README

Usage

$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));

Exporting model

You can export model for efficient serving. Model consume less memory, and serve response faster.

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

Process result

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

Test

Build Status Scrutinizer Code Quality Code Coverage

predictator.eu