predictator / association-rule
1.2.0
2017-02-11 20:09 UTC
Requires
- php: >= 7.0
Requires (Dev)
- fzaninotto/faker: ^1.6
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-11-10 03:01:03 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
predictator.eu