| 1 | <?php |
||
| 10 | class KMeans implements Clusterer |
||
| 11 | { |
||
| 12 | const INIT_RANDOM = 1; |
||
| 13 | const INIT_KMEANS_PLUS_PLUS = 2; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | private $clustersNumber; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var int |
||
| 22 | */ |
||
| 23 | private $initialization; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param int $clustersNumber |
||
| 27 | * @param int $initialization |
||
| 28 | * |
||
| 29 | * @throws InvalidArgumentException |
||
| 30 | */ |
||
| 31 | public function __construct(int $clustersNumber, int $initialization = self::INIT_KMEANS_PLUS_PLUS) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param array $samples |
||
| 43 | * |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | public function cluster(array $samples) |
||
| 60 | } |
||
| 61 |