Regression · Beginner

Linear Regression

Fit a line, inspect residuals, and see gradient descent reduce squared error.

Linear Regression learns a numeric relationship between inputs and a continuous target. In ModelOrigen you can inspect the line, residuals, gradients, parameter updates, and held-out regression metrics as genuine worker states.

Step by step

  1. Start with weight and bias.
  2. Calculate a prediction for each training sample.
  3. Measure residuals and mean squared error.
  4. Differentiate the loss to get gradients.
  5. Update weight and bias with the learning rate.
  6. Repeat and compare held-out error.

Core formulas

Prediction

ŷ = w·x + b

The learned line converts the input into a numeric prediction.

Mean squared error

MSE = (1/n) Σ(yᵢ − ŷᵢ)²

Large prediction errors are penalized more strongly.

Gradient update

θ ← θ − α∇L(θ)

The learning rate α controls how far parameters move along the measured gradient.

When to use Linear Regression

  • A numeric target is approximately related to the inputs in a linear way.
  • You want a transparent baseline with interpretable coefficients.
  • You need a simple model before trying more complex regression methods.

Related interactive lessons

Primary references

scikit-learn LinearRegression