-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapriori.php
53 lines (42 loc) · 1.33 KB
/
apriori.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Apriori Alghoritm</title>
</head>
<body style="font-family: monospace;">
<a href="input.php">Input more categoories</a>
<a href="recommend.php">See recommendations</a>
<?php
include 'class.apriori.php';
$Apriori = new Apriori();
$Apriori->setMaxScan(20); //Scan 2, 3, ...
$Apriori->setMinSup(2); //Minimum support 1, 2, 3, ...
$Apriori->setMinConf(75); //Minimum confidence - Percent 1, 2, ..., 100
$Apriori->setDelimiter(','); //Delimiter
/*
Use Array:
$dataset = array();
$dataset[] = array('A', 'B', 'C', 'D');
$dataset[] = array('A', 'D', 'C');
$dataset[] = array('B', 'C');
$dataset[] = array('A', 'E', 'C');
$Apriori->process($dataset);
*/
$Apriori->process('test.txt');
//Frequent Itemsets
echo '<h1>Frequent Itemsets</h1>';
$Apriori->printFreqItemsets();
echo '<h3>Frequent Itemsets Array</h3>';
print_r($Apriori->getFreqItemsets());
//Association Rules
echo '<h1>Association Rules</h1>';
$Apriori->printAssociationRules();
echo '<h3>Association Rules Array</h3>';
print_r($Apriori->getAssociationRules());
//Save to file
$Apriori->saveFreqItemsets('freqItemsets.txt');
$Apriori->saveAssociationRules('associationRules.txt');
?>
</body>
</html>