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.