One k-means assignment and update
Question
Given finite points X and current centres C, implement one k-means assignment/update step. Define the empty-cluster policy and tie rule.
Short answer
Assign each point to its nearest centre; NumPy argmin chooses the first centre on an exact tie. Replace nonempty centres by the assigned point mean and keep an empty centre unchanged. Other empty-cluster policies are possible but must be explicit.
Original question and answer written by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solutionLessons behind this question
Start with a free lesson: Basic Statistics and Regression is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.
Read it free