| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | protected function predictSample(array $sample) |
||
| 20 | { |
||
| 21 | $predictions = []; |
||
| 22 | foreach ($this->labels as $index => $label) { |
||
| 23 | $predictions[$label] = 0; |
||
| 24 | foreach ($sample as $token => $count) { |
||
| 25 | if (array_key_exists($token, $this->samples[$index])) { |
||
| 26 | $predictions[$label] += $count * $this->samples[$index][$token]; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | arsort($predictions, SORT_NUMERIC); |
||
| 32 | reset($predictions); |
||
| 33 | |||
| 34 | return key($predictions); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |