Machine learning can sound like a special kind of magic. It is more useful to ask the same questions we ask of any algorithm: What data goes in? What objective is being improved? What steps change the current answer? When does the method stop, and what can we say about the result?
Background for this page. You need averages and distances. To follow gradient descent fully, you also need derivatives: quantities that describe how an objective changes when a parameter changes. Related explanations: Matrix algorithms: Gaussian elimination and linear systems · Counting, probability, and expectation for algorithms.
In k-means clustering, we choose k centers, assign each data point to its nearest center, then move each center to the mean of its assigned points. We repeat. Each step does not increase the sum of squared distances to assigned centers, so the process settles at a local solution. It need not find the best possible grouping. The starting centers, the chosen k, the distance measure, and scaling of features can all change the result. An empty cluster also needs a stated handling rule.
Multiplicative weights handles a different problem. Imagine several advisers, each making predictions. After seeing a result, reduce the weight of advisers who performed badly and use the remaining weights to guide the next choice. Under bounded losses and a suitable update rate, we can prove a regret bound: across many rounds, the method’s total loss is not much worse than that of the best single adviser chosen in hindsight. That does not mean the method predicts every round correctly.
Gradient descent tries to reduce a differentiable objective. At a current parameter value x, the gradient points in a direction of local increase, so we take a step against it:
x ← x − η∇f(x).
Here η is the learning rate, or step size. Too large a step can overshoot; too small a step can make progress slow. For a convex objective, conditions on the function and step choices can support a global guarantee. For a nonconvex objective, the method may stop near a local minimum or another stationary point. The mathematics of the objective matters more than the name of the tool.
These three methods show different meanings of “learn.” K-means groups data without given labels. Multiplicative weights adapts to feedback over rounds. Gradient descent optimizes parameters of a chosen function. None of them removes the need to check data quality, choose an objective that fits the real task, and evaluate results on data not used to fit the method.
Run a k-means iteration by hand
Use one-dimensional points 1, 3, 8, and 10, with initial centers 2 and 8. The first two points join center 2; the last two join center 8. Their means are 2 and 9, so move the second center to 9. Squared error falls from 1+1+0+4=6 to 1+1+1+1=4. Another assignment step keeps the same groups, so this example has stabilized.
For fixed assignments, the mean minimizes squared distance within each group. For fixed centers, assigning to the nearest center cannot increase the objective. These facts explain the alternating improvement. They do not establish a global optimum over all possible groupings. Empty clusters and distance ties require explicit policies.
A lower training objective also does not prove usefulness. Cluster quality depends on the question, features, and distance measure; predictive models need evaluation on suitable held-out data.
Practice. Why can two runs of k-means on the same data give different clusters? If gradient descent reduces the training objective, what question remains before trusting it on new data?
Answer. Different starting centers can lead to different local solutions. A lower training objective does not by itself show that the model works on new data; we need suitable evaluation outside the training set.
Try another case. Does rescaling one feature leave Euclidean-distance clustering unchanged?
Reasoning. Not generally. A feature measured on a much larger scale can dominate distance and change assignments. Feature scaling is part of the modeling decision.