This interactive demo shows how gradient descent optimizes linear regression parameters. Unlike analytical solutions, gradient descent iteratively improves parameters by following the negative gradient of the cost function.
You'll see the algorithm step-by-step, watching how the regression line evolves and tracking the optimization path on the cost surface. This is the foundation for training machine learning models.
• Click "Step" to perform one gradient descent iteration. Watch the regression line evolve (left panel) and the optimization path on the cost surface (right panel)
• Use "Re-initialize" to start from new random parameters, or load different datasets to explore various optimization landscapes
• Adjust the learning rate to see different convergence behaviors—too small is slow, too large causes oscillation
What learning rate gives the fastest convergence without overshooting? Try values from 0.01 to 0.5.
• Data & Regression Line (top-left): Normalized data points, current regression line, residuals (dashed red lines showing prediction errors)
• Cost Surface (top-right): Cost surface contours, current position (red dot), optimization path (yellow line)
• Cost Improvement (bottom): Bar chart showing (absolute cost reduction) for each iteration. Watch how the improvements diminish as the algorithm converges to the optimal solution
• Readouts: Current iteration, normalized parameters and , cost , and gradient norm
• Caption: Shows what happened in each step (gradient computation, parameter updates, and )
• As convergence approaches, both the gradient norm and decrease toward zero