Machine learning: fitting a line, finding a group
Supervised and unsupervised learning, side by side and small enough to see. In the regression panel you have known answers, and the model fits a line that minimises its error against them — move the points and watch the line chase. In the clustering panel there are no answers at all; the algorithm partitions the space by proximity, and you choose how many groups it looks for. Change that number and clusters appear that mean nothing. That is the lesson worth carrying: clustering will always return groups, and whether they correspond to anything real is a question the algorithm cannot answer for you.
Supervised learning
Linear regression
Regression finds the straight line that best predicts y from x. Add noise and watch how confidently the line still captures the trend — measured by R².
Spread of points around the true line.
The line minimizes squared error. More noise lowers R² but the fit stays unbiased.
Unsupervised learning
k-means clustering
With no labels, k-means groups points by closeness. Pick how many clusters to look for, then step through the algorithm as centroids settle into the data.
How many groups to find.
Each step reassigns points to the nearest centroid, then moves centroids to their mean — until nothing changes.