# Implement K-means Clustering

0

You are given a 2D numpy array where each row represents a different data point and each column represents a feature. Your task is to classify these data points into k clusters using the K-means clustering algorithm.

Steps:

1. Initialize the centroids randomly from the data points.

2. Assign each data point to the nearest centroid.

3. Update the centroids as the mean of the assigned data points.

4. Repeat steps 2 and 3 until convergence or until a set number of iterations is reached.

### Examples:

1.0

2.0

5.0

5.0

1.0

1.5

8.0

8.5

2

↓

0

1

0

1

1.0

1.0

2.0

2.0

9.0

9.0

8.0

8.0

2

↓

1

1

0

0

Loading...