Professional Documents
Culture Documents
EUC1502 Module4 Machine-Learning
EUC1502 Module4 Machine-Learning
Non-linear
machine learning
econometrics:
Support Vector Machine
THE CONTRACTOR IS ACTING UNDER A FRAMEWORK CONTRACT CONCLUDED WITH THE COMMISSION
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Introduction
Non-linear models
Polinomial regression
Generalized additive models
Decision Trees
Support Vector Machines
Etc.
2
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Introduction: hyperplanes
Hyperplane:
In a p-dimensional space, an hyperplane is a “flat” affine
subspace of dimension p-1
p=2 line
p=3 plane
Definition:
p=2 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 =0 line equation
p-dimensions 𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + ⋯ + 𝛽𝑝 𝑋𝑝 =0
3
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Introduction: hyperplanes
Geometric interpretation:
If X= (X1, X2,…,Xp)T satisfies the above equation X lies on
the hyperplane
If
𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + ⋯ + 𝛽𝑝 𝑋𝑝 >0 or
𝛽0 + 𝛽1 𝑋1 + 𝛽2 𝑋2 + ⋯ + 𝛽𝑝 𝑋𝑝 <0
Example:
1.5
1+2X1+3X2>0
1.0
0.5
1+2X1+3X2=0
X2
0.0
−0.5
−1.0
1+2X1+3X2<0
−1.5
Separating hyperplanes:
Problem:
If a hyperplane exists, then there exists an infinite number of
other hyperplanes that could separate the data
Possible solution:
select the one that is the farthest
from the data
7
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Maximal margin classifier
3
the margin is largest
2
X2
1
margin: minimal distance from distance
0
the observations to the
hyperplane −1
X1
1 2 3
3
A test observation will be
classified depending on which
2
side of the maximal margin
Support vectors
X2
hyperplane it lies
1
0
−1
−1 0 1 2 3
X1
9
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Maximal margin classifier
• n training observations x1, x2,…,xn
• p dimensions
• y1, y2,…,yn ∈ 1, −1
• M width of margin
• Optimisation problem: Maximise M for 𝛽0 , 𝛽1 , 𝛽2 , … , 𝛽𝑝
• subject to:
𝑝
• σ𝑗=1 𝛽2 𝑗 = 1
• yi (𝛽0 + 𝛽1 𝑋i1 + 𝛽2 𝑋i2 + ⋯ + 𝛽𝑝 𝑋i𝑝 ) ≥M for
each i=1,..n
Problems:
▪ it cannot be applied if no
separating hyperplane
exists
Solution:
Support vector classifier
11
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
12
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
How it works:
• Optimisation problem:
• Maximise M for 𝛽0 , 𝛽1 , 𝛽2 , … , 𝛽𝑝 , 𝜖1 , … 𝜖𝑛
• subject to:
𝑝
• σ𝑗=1 𝛽𝑗2 = 1
• yi (𝛽0 + 𝛽1 𝑋i1 + 𝛽2 𝑋i2 + ⋯ + 𝛽𝑝 𝑋i𝑝 ) ≥M(1-𝜖𝑖 ),
for each i=1,..n
𝜖𝑖 ≥ 0, σ𝑛𝑖=1 𝜖𝑖 ≤ C
𝜖1 , … 𝜖𝑛 =
slack variables that allow individual observations to be on the
wrong side of the margin or the hyperplane
C= non-negative tuning parameter
13
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
14
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
About C:
15
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
C higher Lower C
16
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support vector classifier
Property:
17
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support Vector Machines
18
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support Vector Machines
Maximise M
𝛽0 , 𝛽11 , 𝛽12 … 𝛽𝑝1 , 𝛽𝑝2 , 𝜖1 , … 𝜖𝑛
Subject to
2
𝑝 2
σ𝑗=1 𝛽𝑗𝑘 = 1,
𝑘=1
𝑝 𝑝
yi (𝛽0 + σ𝑗=1 𝛽j1 xij + σ𝑗=1 𝛽j2 2x2ij) ≥M(1-𝜖𝑖 ),
𝜖𝑖 ≥ 0, σ𝑛𝑖=1 𝜖𝑖 ≤ C
19
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support Vector Machines
𝑝
𝐾 (𝑥𝑖 , 𝑥𝑖′ ) =exp(−γ σ𝑗=1 𝑥𝑖𝑗 𝑥𝑖 ′ 𝑗 2) radial kernel
20
Eurostat
Machine-learning non-linear estimation methods: Support Vector Machines
Support Vector Machines
Examples:
4
4
2
2
X2
X2
0
0
−2
−2
−4
−4
−4 −2 0 2 4 −4 −2 0 2 4
X1 X1
23
Eurostat