Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
1 | <?php |
||
93 | private function kNeighborsDistances(array $sample): array |
||
94 | { |
||
95 | $distances = []; |
||
96 | |||
97 | foreach ($this->samples as $index => $neighbor) { |
||
98 | $distances[$index] = Distance::euclidean($sample, $neighbor); |
||
99 | } |
||
100 | |||
101 | asort($distances); |
||
102 | |||
103 | return array_slice($distances, 0, $this->k, true); |
||
104 | } |
||
105 | } |
||
106 |