Skip to content

Incorrect quadratic residuals calculation in "Linear Regression" tutorial #4

@robert-horn

Description

@robert-horn

Your code for calculating the residuals for the quadratic regression contains this line:

    fit_line = x*a0**2 + x*a1 + a2

Which leads to the output that the sum of residuals is -584

In fact, the line should be

    fit_line = a0*x**2 + x*a1 + a2

as the coefficient is for the x^2 term, not the root of the coefficient for the x term

When corrected, this gives the output that the sum of the residuals is actually 1.4139800441625994e-12, which is actually much smaller than the residual for the linear fit!

This entirely invalidates the paragraph which follows it, which explains why the number is so large.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions