-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApriori.php
89 lines (77 loc) · 2.43 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* This file is part of the CodedHeartInside package.
*
* (c) Wim Ulkeman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* For Contributing on the code, please view the CONTRIBUTING file that was
* distrubuted with this source code
*/
namespace CodedHeartInside\DataMining\Apriori;
use CodedHeartInside\DataMining\Apriori\ConfigurationInterface;
use CodedHeartInside\DataMining\Apriori\Threshold;
use CodedHeartInside\DataMining\Apriori\Support;
/**
* Class Apriori
* @package CodedHeartInside\DataMining\Apriori
*
* @api
*/
class Apriori
{
/**
* @var \CodedHeartInside\DataMining\Apriori\ConfigurationInterface
*/
private $projectConfiguration;
/**
* @var \CodedHeartInside\DataMining\Apriori\Threshold
*/
private $threshold;
/**
* @var \CodedHeartInside\DataMining\Apriori\Support
*/
private $support;
private $confidence;
/**
* @param \CodedHeartInside\DataMining\Apriori\ConfigurationInterface $configuration
*/
public function __construct(ConfigurationInterface $configuration)
{
$this->projectConfiguration = $configuration;
$this->threshold = new Threshold($configuration);
$this->support = new Support($configuration);
$this->confidence = new Confidence($configuration);
}
/**
* This function is called after the configuration for the algorithm is set. The function will return the
* given data set and return the support and confidence of each transaction.
*/
public function run()
{
$this->threshold->createThresholdForDataSet();
$this->support->createSupportOnThresholdFile();
$this->confidence->createConfidenceOnThresholdFile();
}
/**
* This function is called to retrieve the records with the support percentage for the provided dataset after
* the algorithm has been run.
*
* @yield The record with the item set and the support
*/
public function getSupportRecords()
{
return $this->support->getSupportRecords();
}
/**
* Tihs function is called to retrieve the records with the confidence percentage between items in item sets
*
* @yield The record with the item set and the underlying confidence
*/
public function getConfidenceRecords()
{
return $this->confidence->getConfidenceRecords();
}
}