8
K-meansアルゴリズムのゴルフ
K-meansは標準の教師なしクラスタリングアルゴリズムであり、一連の「ポイント」といくつかのクラスターKが与えられると、各「ポイント」をK個のクラスターのいずれかに割り当てます。 K平均の疑似コード K-meansには多くのバリアントがあることに注意してください。以下で説明するアルゴリズムを実装する必要があります。同じ初期点が与えられた場合にこのアルゴリズムと同じ結果が得られる限り、アルゴリズムにいくつかのバリエーションを持たせたり、組み込みを使用したりできます。 この課題では、すべての入力が2D平面上の点になります(各点は、xとyの座標で表されます)。 Inputs: K, the number of clusters P, the set of points Choose K points of P uniformly at random Each chosen point is the initial centroid of its cluster Loop: For each point in P: Assign to the cluster whose centroid is the nearest (Euclidean distance) …