Fit a straight-line rule

Linear regression predicts a number by combining a baseline with weighted feature values.

The idea

Start with a baseline, then add or subtract a fixed amount for each unit of a clue. That creates a straight-line prediction.

For one feature, ŷ = wx + b. The slope w controls how much the prediction changes with x; b is the intercept. Training minimizes a regression loss.

How it works

  1. Represent each example with numeric features.
  2. Multiply features by coefficients and add the intercept.
  3. Compare predictions with observed targets to obtain residuals.
  4. Fit coefficients to minimize a loss such as residual sum of squares; then evaluate residual behavior on held-out data.

Linear prediction and ordinary least squares

The prediction is an affine function of the features. Ordinary least squares chooses coefficients that minimize squared residuals.

ŷ = Xw + b, minimize Σᵢ(yᵢ − ŷᵢ)²

Check your understanding

In ŷ = wx + b, what does w control?

Answer and explanation

w is the feature weight (slope in one dimension). Changing it changes how strongly x affects the prediction.

A common misconception

A positive coefficient means positive fitted association conditional on the other included features; it does not automatically mean changing that feature will causally change the target.

Open Linear Regression visualizer

ML Basics

Learn the learning loop before diving into individual models: data, splits, regression, and probabilities.

  1. Clues in, answer out
  2. Practice is not the exam
  3. Fit a straight-line rule
  4. Turn a score into a probability