Skip to content
C

Problem 1: Apply K-Means with a Known Number of Clusters

Easypython

Problem Description

Write a Python program that applies K-Means with k=2 to a small 2D dataset containing two visually distinct groups, and prints the resulting cluster assignments.

Input

A 2D dataset with two visually distinct groups.

Output

The cluster label assigned to each point.

Constraints

  • At least 6 points total.

Example Input

text
[[2,3],[3,3],[2,4],[8,8],[9,8],[8,9]]

Example Output

text
Cluster assignments: [0 0 0 1 1 1] (or [1 1 1 0 0 0] — exact labels may vary)

Concepts Covered

KMeans, n_clusters, .fit(), .labels_.

Input (stdin)

Output

Run your code to see output here...