Conditions | 3 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | public function cluster(array $samples): array |
||
42 | { |
||
43 | $space = new Space(count(reset($samples))); |
||
44 | foreach ($samples as $key => $sample) { |
||
45 | $space->addPoint($sample, $key); |
||
46 | } |
||
47 | |||
48 | $clusters = []; |
||
49 | foreach ($space->cluster($this->clustersNumber, $this->initialization) as $cluster) { |
||
50 | $clusters[] = $cluster->getPoints(); |
||
51 | $arrayCluster = $cluster->toArray(); |
||
52 | $this->centronoids[] = $arrayCluster['centroid']; |
||
53 | } |
||
54 | |||
55 | return $clusters; |
||
56 | } |
||
63 |