Polynomial Fit & Overfitting
Fit a polynomial, compare training and validation errors, then evaluate held-out test data.
About this tool
Compare polynomial degree and Ridge α on fixed data. Start with the overfitting example: lower the degree and compare validation MSE, the mean squared prediction error. More flexible models can fit training data better while predicting new data worse.
Data are split reproducibly into about 60% training,20% validation and the remainder test. Only training fits the model. Changing degree or α preserves the data and split. Evaluate test data after choosing the model; repeated tuning using that score removes its independence.
Generate 30–1000 points or import two numeric CSV/TSV columns, with optional x,y header, up to 1 MiB. Coordinates must be finite and within±10⁶; malformed rows are errors. Functions support x, sin(x), Math.sin(x), ^/**, comparisons and conditional expressions. Gaussian σ, uniform half-width and Laplace b allow 0–5; salt-and-pepper probability p allows 0–1. The seed controls data and split. Large imported text may exceed saved-state capacity.
Degree 0–16, α0–10⁶. The objective is Σ(y−Σwⱼzʲ)²+αΣⱼ≥1 wⱼ², with training-only z=(x−center)/scale. The intercept is unpenalized; α=0 is ordinary least squares. QR solves the augmented system and reports rank deficiency. α depends on this normalized monomial basis and sample size.
Complexity compares degrees on the same split; learning curves use nested training prefixes and fixed validation. Tables and coefficients are in details. Linear error axes and the 1025-point fitted curve include all displayed values, so large excursions can compress smaller features. This tool uses holdout validation, not cross-validation, formal bias–variance decomposition or double descent.