📉 Regression Lab
Fit regression models, inspect residuals, and learn why a better in-sample fit does not always mean a better prediction. Your CSV stays in your browser.
Dataset & model
Start with a synthetic dataset or upload your own two-column numeric CSV (header optional).
Format: x,y with one observation per row. Maximum 2,000 rows. Comma-separated, no quoted commas.
Uses ordinary least squares on scaled X values. Train/test split is deterministic and shuffled. For educational purposes, not a production forecasting system.
Model performance
Observed data & fitted curve
Training points Test points Fitted model
Residual diagnostics
Residual = observed Y − predicted Y. Ideally, residuals have no systematic pattern. A curved residual pattern may indicate model misspecification.
Model predictions
| Set | X | Actual Y | Predicted Y | Residual |
|---|---|---|---|---|
| Fit a model to see predictions. | ||||
Learn the concepts
What does ordinary least squares minimize?
It selects coefficients that minimize the sum of squared differences between observed and predicted values. Squaring makes large errors more influential.
What do R², MAE and RMSE mean?
R² compares squared prediction errors with predicting the mean; it can be negative on held-out data. MAE is average absolute error. RMSE is the square root of average squared error and penalizes larger mistakes more heavily.
Why use a train/test split?
Evaluating only on the same data used for fitting can be optimistic. A held-out test set provides a basic check of out-of-sample generalization. For time-series data, use a chronological split instead of random shuffling.
Why can a high-degree polynomial overfit?
A flexible model may follow random noise instead of the underlying relationship. Compare training and test errors, and avoid extrapolating polynomials beyond the observed X range.
What are the limitations?
This browser tool handles one numeric predictor and one numeric outcome, using unregularized polynomial least squares. It does not infer causality, handle missing values, perform inference on coefficients, or automatically select a model.