FunctionRacerProblemsRace

Centers of the Groups

Mediumscikit-learnPython

The rows of X are points that fall into k well separated groups, and nobody has labeled them. Find the groups with k-means (n_init=10, random_state=0) and return the group centers, sorted by their first coordinate. Answers within 0.01% are accepted.

Example 1

X [[0,0],[0,2],[2,0],[2,2],[10,10],[10,12],[12,10],[12,12]]
k 2
returns [[1.0,1.0],[11.0,11.0]]

Four points around (1, 1) and four around (11, 11).

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More scikit-learn problems