Interactive explainer

Regression and overfitting – interactive calculator

A curve can fit familiar observations extremely well and predict new ones poorly. Compare polynomial degrees on the same training and holdout data, and see when additional flexibility becomes harmful.

Compare a polynomial curve’s training fit with its performance on 80 independent holdout observations. All observations are synthetic. The true relationship combines a sine curve with a linear component, plus adjustable noise. Calculations run locally in your browser and do not require your own data.

Interactive

Regression and overfitting – interactive calculator

Only training observations determine the fitted curve. Degrees one to twelve change flexibility; the holdout remains fixed when training size changes.

Three experiments

  1. Increase flexibility. Start at degree one and increase it gradually. Compare training and holdout error. Look for a range where the training fit improves but predictions for the comparison observations no longer benefit. Inspect the curve as well as the numbers.
  2. Add more noise. Hold degree and sample size fixed, then increase noise. The same random draws are scaled more strongly. Watch whether the curve follows individual deviations and swings between observed points.
  3. Use more data. Compare 16 and 60 training observations at a high degree. Additional observations extend the same sample; the 80 holdout observations stay unchanged. Reset everything afterwards.

What the errors tell you

Mean squared error gives large deviations particularly strong weight. The table reports it for all twelve degrees. Numerically stable computation does not prevent overfitting; large excursions can be a correctly calculated result. Repeatedly using the holdout to select the best degree means that fresh test data will be needed later. The regression and overfitting article explains data separation, assumptions and common mistaken conclusions.

From NyxAI

smartlytics is the learning hub of NyxAI GmbH.

Explore the methods we work with, explained openly, with sources and calculations you can reproduce.

Decision Core

NyxAI is developing a Decision Core for Decision Intelligence that combines optimisation, simulation, statistics and reinforcement learning: compare options, make uncertainty visible and learn from outcomes, with people in control.

AI workflows at NyxAI

DeepSquare

Explainable chess AI with human playing styles: NyxAI’s testing ground for understandable decisions under time pressure.