File: example.php

Recommend this page to a friend!
  Classes of Dave Smith  >  PHP Apriori Algorithm Data Miner  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: PHP Apriori Algorithm Data Miner
Reduce a set of transactions to a smaller group
Author: By
Last change:
Date: 6 years ago
Size: 1,171 bytes
 

Contents

Class file image Download
<?php
/*
data mining using apriori algorithm
apriori class 0.1 beta
*/

//include class
include('apriori.class.php');

//instantiate object with minimum support count
$apriori = new apriori(2);

//add transactions with unique Transaction ID, Item List
$apriori->addTransaction('100','{1,3,4}');
$apriori->addTransaction('200','{2,3,5}');
$apriori->addTransaction('300','{1,2,3,5}');
$apriori->addTransaction('400','{2,5}');

//item list does not have to be enclosed in curly brackets
$apriori->addTransaction('500','1,3,5');

//duplicate transaction ID's are ignored
$apriori->addTransaction('300','{2,3,5,6}');


//process transactions
$apriori->processTransactions();

//get frequent item sets in list format
$results = $apriori->formattedSet();

//display
echo 'Number of transactions: '.count($apriori->tranactionList).'<br><br>';
echo
'Number of unique items: '.count($apriori->itemList).'<br><br>';
echo
'Minimun Support Count: '.$apriori->minSupportCount.'<br><br>';
echo
'Number of iterations: '.$apriori->iteration.'<br><br>';
echo
'Frequent item sets<br>';
foreach(
$results as $result){
    echo
$result.'<br>';
}

?>

For more information send a message to info at phpclasses dot org.