protected function initialize(Dataset $dataset) : array
    {
        $centroids = $this->seeder->seed($dataset, $this->k);

        $kernel = new Euclidean();

        $clusters = array_fill(0, $this->k, []);

        foreach ($dataset as $sample) {
            $bestDistance = INF;
            $bestCluster = -1;
    
            foreach ($centroids as $cluster => $centroid) {
                $distance = $kernel->compute($sample, $centroid);
    
                if ($distance < $bestDistance) {
                    $bestDistance = $distance;
                    $bestCluster = $cluster;
                }
            }

            $clusters[$bestCluster][] = $sample;
        }

        $means = $variances = [];

        foreach ($clusters as $cluster => $samples) {
            $mHat = $vHat = [];

            $columns = array_map(null, ...$samples);

            foreach ($columns as $values) {
                [$mean, $variance] = Stats::meanVar($values);

                $mHat[] = $mean;
                $vHat[] = $variance;
            }

            $means[$cluster] = $mHat;
            $variances[$cluster] = $vHat;
        }

        return [$means, $variances];
    }