Skip to content

    Polynomial Regression

    Machine Learning · Intermediate

    Definition

    Polynomial regression fits curves by adding powers of features (x², x³) to linear regression.

    Captures non-linear trends with a linear model.

    Diagram

    y = b0 + b1x + b2x²

    Flowchart

    Create x, x², …Fit linear regressionPick degree with validationWatch for overfitting

    Example: Evaluate a fitted curve

    b0, b1, b2 = 1, 2, 0.5
    print([b0 + b1 * x + b2 * x ** 2 for x in [0, 2, 4]])

    Output: [1.0, 7.0, 17.0]

    Key points

    • High degree overfits
    • Scale features before fitting

    Interview questions

    Is it still linear regression?

    Yes — linear in the coefficients, even though curved in x.

    More Machine Learning topics