PHP code example of predictator / association-rule

1. Go to this page and download the library: Download predictator/association-rule library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

predictator / association-rule example snippets


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