Linear Regression
Fit a straight line to data by minimising squared error, with gradient descent and with a closed-form solution.
The idea
Linear regression predicts a number as a weighted sum of the inputs. With one feature it is a straight line:
- is the input feature and ("y hat") is the prediction.
- is the weight (slope): how much the prediction changes per unit of .
- is the bias (intercept): the prediction when is 0.
With many features it is , which in NumPy is X @ w + b. The task: find and that fit the data.
1 of 8