Conditions | 5 |
Paths | 7 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public static function score(array $actualLabels, array $predictedLabels, bool $normalize = true) |
||
21 | { |
||
22 | if (count($actualLabels) != count($predictedLabels)) { |
||
23 | throw InvalidArgumentException::sizeNotMatch(); |
||
24 | } |
||
25 | |||
26 | $score = 0; |
||
27 | foreach ($actualLabels as $index => $label) { |
||
28 | if ($label === $predictedLabels[$index]) { |
||
29 | ++$score; |
||
30 | } |
||
31 | } |
||
32 | |||
33 | if ($normalize) { |
||
34 | $score = $score / count($actualLabels); |
||
35 | } |
||
36 | |||
37 | return $score; |
||
38 | } |
||
39 | } |
||
40 |