[CS5242] Linear Regression
Univariate Linear Regression#
- Maps from input to output
- y~=wx+b
- y~: prediction output
- w: weight
- x: input
- b: bias
- Loss funciton
- to calculate the loss between y~ and y
- L1: L(x,y∣w,b)=∣y~−y∣
- L2: L(x,y∣w,b)=21∣y~−y∣2
- Global loss J(w,b)=m1∑i=1mL(xi,yi∣w,b) (data points are independent to each other)
- minJ(w,b)=minw,b2m1∑i=1m(wxi+b−yi)2
- the 2 in 2m1 is for calculation convenience
- Gradient descent
- optimization
- for each sample, compute y~=wx+b
- compute average loss J(w,b)
- compute ∂w∂J
- update w=w−α∂w∂J, α is learning rate
- update w,b repeatedly
Multivariate Linear Regression#
- features as column vector X=x1x2...xn, x∈Rn×1
- y~=wTx+b,w∈Rn×1,b∈R
- =∑i=1mwixi+b=(w1,w2,...,wn)×x1x2...xn+b
- Gradient of vector and metrix
- J(w)=L(x,y∣w)=21(wTx−y)2
- let Z=wTx−y, J(w)=21Z2
- ∂w∂J(w)=∂Z∂J∂w∂Z=Zx=(wTx−y)x