Return to Algorithms

Polynomial Regression Visualization

Data Points
Polynomial Fit
True Relationship
Residuals

Controls

Data Generation

1.0

Polynomial Regression

Visualization Options

Regression Stats

True Relationship: y = 0.5x² + 1
Fitted Equation: y = ?
MSE (Mean Squared Error): -
R² Value: -
Polynomial Degree: 2

Error vs. Polynomial Degree

How Polynomial Regression Works

What is Polynomial Regression?

Polynomial regression extends linear regression by fitting curves using polynomial functions. Instead of just fitting y = b₀ + b₁x, it fits y = b₀ + b₁x + b₂x² + ... + bₙxⁿ, where n is the degree of the polynomial.

Understanding Model Complexity:

  • Underfitting: Simple models (low degree) may not capture the true pattern in the data
  • Good Fit: Model complexity matches data complexity, capturing patterns without fitting to noise
  • Overfitting: Complex models (high degree) fit the training data nearly perfectly but perform poorly on new data

Bias-Variance Tradeoff:

  • Low Degree Polynomials: High bias (underfitting), low variance
  • High Degree Polynomials: Low bias, high variance (overfitting)
  • The best models balance this tradeoff to minimize total error

Try different data patterns and polynomial degrees to see how the model's ability to fit the data changes. Notice how higher degree polynomials can create wild oscillations, especially near the edges of the data range!