1 | <?php |
||
7 | class ClassificationReport |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | private $precision = []; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | private $recall = []; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $f1score = []; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $support = []; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $average = []; |
||
33 | |||
34 | /** |
||
35 | * @param array $actualLabels |
||
36 | * @param array $predictedLabels |
||
37 | */ |
||
38 | public function __construct(array $actualLabels, array $predictedLabels) |
||
57 | |||
58 | /** |
||
59 | * @return array |
||
60 | */ |
||
61 | public function getPrecision() |
||
65 | |||
66 | /** |
||
67 | * @return array |
||
68 | */ |
||
69 | public function getRecall() |
||
73 | |||
74 | /** |
||
75 | * @return array |
||
76 | */ |
||
77 | public function getF1score() |
||
81 | |||
82 | /** |
||
83 | * @return array |
||
84 | */ |
||
85 | public function getSupport() |
||
89 | |||
90 | /** |
||
91 | * @return array |
||
92 | */ |
||
93 | public function getAverage() |
||
97 | |||
98 | /** |
||
99 | * @param array $truePositive |
||
100 | * @param array $falsePositive |
||
101 | * @param array $falseNegative |
||
102 | */ |
||
103 | private function computeMetrics(array $truePositive, array $falsePositive, array $falseNegative) |
||
111 | |||
112 | private function computeAverage() |
||
119 | |||
120 | /** |
||
121 | * @param float $precision |
||
122 | * @param float $recall |
||
123 | * |
||
124 | * @return float |
||
125 | */ |
||
126 | private function computeF1Score(float $precision, float $recall): float |
||
134 | |||
135 | /** |
||
136 | * @param array $labels |
||
137 | * |
||
138 | * @return array |
||
139 | */ |
||
140 | private static function getLabelIndexedArray(array $labels): array |
||
148 | } |
||
149 |