Chester Zhang
lately
Least Squares: Fitting a Straight Line with Python
Derive the straight-line fitting formula starting from the sum of squared residuals, and use a runnable Python example to plot the observed points, the fitted line, and the residuals.
Read it