You will write four functions that judge a straight-line fit: the residuals, the sum of the squared residuals, the coefficient of determination and a test for a point that changes a lot. The helper fit is already written. It returns the intercept and the slope.
The idea. A residual is , the vertical miss. The residuals of the least squares line add to zero. The coefficient of determination is . A point is influential if removing it changes a lot.
Your tasks.
residuals(x, y).sum_squares(x, y), the sum of the squared residuals.r_squared(x, y).influential(x, y, i). Return True when removing point number i changes by more than .Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…