RosettaCodeData/Task/K-means++-clustering/00-TASK.txt
2023-07-01 13:44:08 -04:00

12 lines
1.7 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[[WP:K-means%2B%2B|K-means++ clustering]] a classification of data, so that points assigned to the same cluster are similar (in some sense). It is identical to the [[WP:K-means_clustering|K-means]] algorithm, except for the selection of initial conditions. [[Image:CircleClusters.png|thumb|right|alt=A circular distribution of data partitioned into 7 colored clusters; similar to the top of a beach ball|This data was partitioned into 7 clusters using the [[WP:K-means_clustering|K-means algorithm]].]]
The task is to '''''implement the K-means++ algorithm'''''. Produce a function which takes two arguments: the number of clusters K, and the dataset to classify. K is a positive integer and the dataset is a list of points in the Cartesian plane. The output is a list of clusters (related sets of points, according to the algorithm).
For '''''extra credit''''' (in order):
# Provide a function to exercise your code, which generates a list of random points.
# Provide a visualization of your results, including centroids (see example image).
# Generalize the function to polar coordinates (in radians).
# Generalize the function to points in an arbitrary N space (i.e. instead of x,y pairs, points are an N-tuples representing coordinates in <sup>N</sup>). <BR>''If this is different or more difficult than the [naive] solution for <sup>2</sup>, discuss what had to change to support N dimensions.''
Extra credit is only awarded if the examples given demonstrate the feature in question. To earn credit for 1. and 2., visualize 6 clusters of 30,000 points in <sup>2</sup>. It is not necessary to provide visualization for spaces higher than <sup>2</sup> but the examples should demonstrate features 3. and 4. if the solution has them.