Three data points x = [0,1,2] with targets [-1,-1,1] are fit by a line f(x) = b + wx, with vertical residuals shown as squared-error contributions. The animation builds the design matrix, forms the normal equations X^T X theta = X^T t, and solves exactly for b = -4/3, w = 1. A separate parameter-space panel shows one gradient-descent step from theta = 0, illustrating that least squares defines the loss while gradient descent is just one way to minimize it. Useful for first-year AI students starting linear regression and optimization.
Narrated · 16:9 · Preview before teaching · automatic layout checks do not establish subject accuracy
# Least squares and gradient descent solve different parts of the problem Show one-dimensional training inputs x = [0,1,2] with targets [-1,-1,1]. A line f(x) = b + wx produces predictions, while vertical residuals become squared-error contributions. Define J = ||X theta - t||^2/(2n), with each design-matrix row equal to [1,x] and theta = [b,w]. Build X^T X = [[3,3],[3,5]] and X^T t = [-1,1], then solve for b = -4/3 and w = 1. The zero-score classification threshold is x = 4/3. In a separate parameter-space view, demonstrate one gradient step from theta = 0 with learning rate 0.3, reaching [-0.1,0.1]. Explain that least squares defines the objective and gradient descent is one way to optimize it. The optimum has squared-error sum 2/3 and J = 1/9. Use black backgrounds and distinguish data space from parameter space throughout. Audience: 一年级人工智能专业学生