What objective function does k-means optimize?

Quick Overview

Asks which objective function k-means minimizes and what that objective implies about centroids, cluster shapes and convergence. Tests whether you can write the loss, connect it to the two steps of Lloyd's algorithm, and reason about choosing the number of clusters.

What objective function does k-means optimize?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What objective function does k-means optimize? K-means is usually taught as a two-step loop (assign points, then move centroids). The question is what quantity that loop is minimizing. ```hint Look at the update step When the cluster assignments are fixed, which single point minimizes the total squared distance to a set of points? ``` ### What a Strong Answer Covers - The objective written out: the quantity summed, the distance used, and what it is minimized over. - Why the minimizing centroid of each cluster is the cluster mean. - How the assignment and update steps of Lloyd's algorithm relate to the objective, and what that guarantees about convergence and optimality. - What kind of clusters the objective favors, and why its value alone cannot choose k. ### Follow-up Questions - If you replace squared Euclidean distance with absolute (L1) distance, what becomes the best "center" of a cluster? - How does k-means++ initialization help with the objective, and why do libraries still run several restarts? - How would you choose k when the objective keeps dropping as k grows? - How does k-means relate to a Gaussian mixture model fitted with EM?

Overview: Asks which objective function k-means minimizes and what that objective implies about centroids, cluster shapes and convergence. Tests whether you can write the loss, connect it to the two steps of Lloyd's algorithm, and reason about choosing the number of clusters.

Nov 24, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

What objective function does k-means optimize?

K-means is usually taught as a two-step loop (assign points, then move centroids). The question is what quantity that loop is minimizing.

What a Strong Answer Covers Guidance

  • The objective written out: the quantity summed, the distance used, and what it is minimized over.
  • Why the minimizing centroid of each cluster is the cluster mean.
  • How the assignment and update steps of Lloyd's algorithm relate to the objective, and what that guarantees about convergence and optimality.
  • What kind of clusters the objective favors, and why its value alone cannot choose k.

Follow-up Questions Guidance

  • If you replace squared Euclidean distance with absolute (L1) distance, what becomes the best "center" of a cluster?
  • How does k-means++ initialization help with the objective, and why do libraries still run several restarts?
  • How would you choose k when the objective keeps dropping as k grows?
  • How does k-means relate to a Gaussian mixture model fitted with EM?