Linear Regression
- Predict a continuous dependent variable with one or more independent variables
- Their relationship must be linear (i.e. multiplying the variable directly with a factor)
- But you can add derive additional features and still use linear regression in the end
- Image: fit a line through a set of points
Model function (Hypothesis)
hθ(x)=θ0+θ1x
Trick for quickly computing several predicted values for one or several hypotheses
Given house sizes: 2104, 1416, 1534, 852
Given hypotheses:
hθ(x)=−40+0.25xhθ(x)=200+0.1xhθ(x)=−150+0.4x
Calc results via:
⎣⎡1111210414161534852⎦⎤×[−400.252000.1−1500.4]
Cost Function
Minimize by θ0 and θ1
J(θ)=2m1∑i=1m(hθ(x(i))−y(i))2
- Squared error function
- Mean squared error
(Batch) Gradient Descent Algorithm
θ0:=θ0−αm1∑i=1m(hθ(x(i))−y(i))
θ1:=θ1−αm1∑i=1m(hθ(x(i))−y(i))∗x(i)
- The Cost function is a convex function (bowl shaped) so it will only ever have one minimum
- It uses all training samples in every step
Resources
Backlinks