Linear-Regression 231212 072619
Linear-Regression 231212 072619
Linear Regression
Tiago Vieira
Institute of Computing
Universidade Federal de Alagoas
February 9, 2023
Summary
Introduction
Solution
Introduction
Figure: Example of linear regression. The black solid line represents f (x) corresponding to the
real phenomenon generating the data. Blue dots represent the samples obtained after the
insertion of the noise. The blue solid line represents the model obtained by linear regression.
Introduction
Linear regression:
Input:
x ∈ Rn . (1)
Output is a linear function of the input:
y ∈ R. (2)
That is:
x1
x2
∈ Rn 7→ y ∈ R (3)
..
.
xn
▶ Parameters are values that control the behavior of the system.
▶ wi are coefficients that are multiplied by feature xi before adding the
contributions of all attributes.
▶ [wi ] is a set of weights determining how much each attribute contributes to the
prediction ŷ.
▶ wi > 0 : ↑ xi ↑ ŷ
▶ wi < 0 : ↑ xi ↓ ŷ
▶ wi = 0 : xi has no influence on ŷ
▶ wi ≫ 0 : xi has a large influence on ŷ
Problem statement:
▶ Task T : Predict y from a given input x by computing ŷ = wT x.
Suppose:
▶ Design matrix containing m examples:
h im
X test = − − x(i) − − (4)
i=1
∇w M SE(train) = 0 (8)
1 (train)
∇w ||ŷ − y (train) ||22 = 0
m
1 (train) (train)
∇w ||X(m,n) w(n,1) − y(m,1) ||22
m
Solving for w gives:
−1
w = XT X XT y (9)