Implement the k-means clustering algorithm for 2D points. Given arrays of x and y coordinates for data points, initial centroids, and other parameters, assign each point to the nearest centroid and update the centroids iteratively. The final centroids and labels should be stored in the output arrays.
solve function signature must remain unchangedlabels, final_centroid_x, and final_centroid_yInput: sample_size = 4, k = 2, max_iterations = 10 data_x = [1.0, 2.0, 8.0, 9.0] data_y = [1.0, 2.0, 8.0, 9.0] initial_centroid_x = [1.0, 8.0] initial_centroid_y = [1.0, 8.0] Output: (see reference implementation for expected output)
k = 5, max_iterations = 30, sample_size = 10,000