Supervised LearningLinear RegressionRegression

Polynomial Regression

Primary task · Regression

Ordinary Least Squares (Polynomial Regression) is the canonical linear regression model. It estimates coefficients that minimize squared prediction error and provides an interpretable baseline for continuous targets.

← Directory
Visual intuition

From data to learned behaviour

Polynomial Regression converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Infographic
1Data2Initial state3Optimise4Validate5InferenceTraining transforms evidence into a reusable model state
Conceptual simulation

Watch the learning mechanism form

The structure below is synchronized with the same training state used by the prediction simulation.

Mechanism view
Training control centre

Control both simulations together

Reset regenerates the synthetic data and model state. Train animates to completion. Pause freezes the animation. Train Step advances one learning stage.

Step 0 / 20
Model simulation

Inspect the learned prediction / representation

Synthetic data are generated locally in your browser.

Model description

Understand Polynomial Regression after watching it learn

This section connects the animation to the actual statistical or computational idea behind the model.

Deep description

Polynomial Regression Ordinary Least Squares (Polynomial Regression) is the canonical linear regression model. It estimates coefficients that minimize squared prediction error and provides an interpretable baseline for continuous targets.

What is learned. During training, the algorithm builds or adjusts the parameters and internal representation used by Polynomial Regression. The core learning mechanism is: Expands numeric inputs into polynomial and interaction features, then fits a linear model in that expanded feature space. This creates curved response surfaces while keeping coefficients explicit.

How training becomes inference. Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference. Once training stops, the fitted state is reused on unseen inputs rather than being reconstructed from scratch. The resulting output is: A continuous numeric prediction; some probabilistic variants can also provide uncertainty or intervals.

Why practitioners use it. Fast, transparent coefficients, closed-form solution when assumptions and matrix conditioning permit. Typical fits include Interpretable baseline regression, trend estimation, econometrics, calibration, effect-size analysis.

What to verify before trusting it. Sensitive to outliers and multicollinearity; only linear in the chosen features unless features are transformed. The visual simulation is intentionally simplified, so real use should still validate preprocessing, data independence, hyperparameters, uncertainty and task-appropriate metrics.

Internal statethe parameters and internal representation used by Polynomial Regression
Typical outputA continuous numeric prediction; some probabilistic variants can also provide uncertainty or intervals.
Good fitInterpretable baseline regression, trend estimation, econometrics, calibration, effect-size analysis.
Main cautionSensitive to outliers and multicollinearity; only linear in the chosen features unless features are transformed.
1Training data→
2Learning objective→
3Internal model state→
4Prediction / representation→
5Evaluation
Intuition

What the model is trying to learn

Polynomial Regression converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Mathematical lens

Core logic

Expands numeric inputs into polynomial and interaction features, then fits a linear model in that expanded feature space. This creates curved response surfaces while keeping coefficients explicit. The mathematical objective determines which model states are considered better, while regularisation and validation constrain how much complexity should be trusted.

Training sequence

How learning progresses

Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference.

Original mechanism

Taxonomy description

Expands numeric inputs into polynomial and interaction features, then fits a linear model in that expanded feature space. This creates curved response surfaces while keeping coefficients explicit.

Evaluation guide

How to evaluate this model responsibly

ValidationK-Fold; Group K-Fold for repeated entities; time-aware splits for temporal targets.
MetricsMAE and RMSE together, plus R²; inspect residuals rather than trusting one aggregate score.
HPORandom/Bayesian optimisation for continuous hyperparameters; use nested CV when model selection is intensive.
Post-processingInverse target transforms, clipping only with domain justification, and prediction intervals where uncertainty matters.
Hyperparameters

Key parameters

fit_interceptTypical: True

Whether to estimate an intercept.

positiveTypical: False

Optionally constrain coefficients to be non-negative.

Use & trade-offs

Where it fits

Typical applications

Interpretable baseline regression, trend estimation, econometrics, calibration, effect-size analysis.

Strengths

Fast, transparent coefficients, closed-form solution when assumptions and matrix conditioning permit.

Limitations

Sensitive to outliers and multicollinearity; only linear in the chosen features unless features are transformed.

Code example

Minimal Python implementation

# Purpose: fit a curved regression relationship using polynomial features.
# A straight line underfits this deliberately nonlinear miniature dataset.
import numpy as np
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error

# STEP 1 — create a small curved dataset.
x = np.linspace(-3, 3, 18)
X = x.reshape(-1, 1)
y = 1.5 + 0.7*x + 0.9*x**2
print("STEP 1 · rows:", len(X))

# STEP 2 — compare a degree-1 line with a degree-2 polynomial model.
linear = make_pipeline(PolynomialFeatures(1, include_bias=False), LinearRegression()).fit(X, y)
poly2 = make_pipeline(PolynomialFeatures(2, include_bias=False), LinearRegression()).fit(X, y)
rmse_linear = mean_squared_error(y, linear.predict(X)) ** 0.5
rmse_poly2 = mean_squared_error(y, poly2.predict(X)) ** 0.5
print("STEP 2 · linear RMSE:", round(rmse_linear, 3))
print("STEP 3 · degree-2 RMSE:", round(rmse_poly2, 3))

# STEP 3 — inspect one prediction from the curved fit.
print("STEP 4 · prediction at x=2:", round(float(poly2.predict([[2]])[0]), 3))
Expected / representative output
STEP 1 · rows: 18
STEP 2 · linear RMSE: 2.687
STEP 3 · degree-2 RMSE: 0.0
STEP 4 · prediction at x=2: 6.5