SlideShare a Scribd company logo
1 of 17
Download to read offline
SUPPORT VECTOR MACHINES
Sarith Divakar M
LBS College of Engineering, Kasaragod
sarith@lbscek.ac.in
Support Vector Machines
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
2
Decision Boundary
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
3
Decision Rule
𝑤
𝑢
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
4
𝑤. 𝑢 ≥ C, Then +ve
𝐶 = −𝑏𝑤. 𝑢 + b ≥ 0, Then +ve
Constraint
𝑤
𝑢
𝑤. 𝑥+ + b ≥ 1 1
𝑤. 𝑥− + b ≤ -1 2
𝑦𝑖(𝑤. 𝑥𝑖 + b) ≥ 1
𝑦𝑖 = 1 for Positive Samples
𝑦𝑖 = -1 for Negative Samples
𝑦𝑖(𝑤. 𝑥𝑖 + b) ≥ 1
𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 ≥ 0
𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 for 𝑥𝑖 in the gutter
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
5
Width of the street
𝑊𝑖𝑑𝑡ℎ = (𝑥+ - 𝑥− ) .
𝑤
||𝑤||
For +ve samples 𝑦𝑖=1 and –ve samples 𝑦𝑖 = -1
𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 3
1.(𝑤. 𝑥𝑖 + b) −1 = 0
𝑤. 𝑥𝑖 = 1-b
i
-1.(𝑤. 𝑥𝑖 + b) −1 = 0
𝑤. 𝑥𝑖 = -1-b
ii
𝑊𝑖𝑑𝑡ℎ = (1-b – (-1-b)) .
1
||𝑤||
𝑥+
𝑥−
𝑥+ - 𝑥−
𝑊𝑖𝑑𝑡ℎ =
2
||𝑤||
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
6
Maximize Width of the street
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 =
2
||𝑤||
𝑥+
𝑥−
𝑥+ + 𝑥−
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 =
1
||𝑤||
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 = ||𝑤||
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 =
1
2
||𝑤||
2
4
𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
7
Optimization using Lagrange multipliers
Expression: 𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 =
1
2
||𝑤||
2
Constraint: 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0
L=
1
2
||𝑤||
2
- 𝛼𝑖 [𝑦𝑖(𝑤. 𝑥𝑖 + b) − 1]
𝜕𝐿
𝜕𝑤
= 𝑤- 𝛼𝑖 𝑦𝑖 𝑥𝑖 = 0
𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖 6
𝜕𝐿
𝜕𝑏
= - 𝛼𝑖 𝑦𝑖 = 0
𝛼𝑖 𝑦𝑖 = 0 7
5
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
8
Optimization using Lagrange multipliers
7
L=
1
2
||𝑤||
2
- 𝛼𝑖 [𝑦𝑖(𝑤. 𝑥𝑖 + b) − 1]
𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖
5
6
𝛼𝑖 𝑦𝑖 = 0
L=
1
2
( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- 𝛼𝑖 [𝑦𝑖(( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )𝑥𝑖 + b) − 1]
L=
1
2
( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- ( 𝛼𝑖 𝑦𝑖 𝑥𝑖). ( 𝛼𝑗 𝑦𝑗 𝑥𝑗) − 𝛼𝑖 𝑦𝑖 b + 𝛼𝑖
= 0
L= 𝛼𝑖 +
1
2
( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- ( 𝛼𝑖 𝑦𝑖 𝑥𝑖). ( 𝛼𝑗 𝑦𝑗 𝑥𝑗)
L= 𝛼𝑖 −
1
2
𝛼𝑖 𝑦𝑖 𝛼𝑗 𝑦𝑗 (𝑥𝑖. 𝑥𝑗)
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
9
Decision Rule
f(𝑢) = 𝛼𝑖 𝑦𝑖(𝑥𝑖 . 𝑢) - b
?
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
10
SVM Classifier
L= 𝛼𝑖
−
1
2
𝛼𝑖 𝑦𝑖 𝛼𝑗 𝑦𝑗 (𝑥𝑖. 𝑥𝑗)
Compute 𝑤 and b
Find vector 𝛼 which maximizes
Subject to
𝛼𝑖 𝑦𝑖 = 0
SVM Classifier Function:
𝑏 =
1
2
(𝑚𝑖𝑛𝑖:𝑦 𝑖=+1(𝑤. 𝑥𝑖) + 𝑚𝑎𝑥𝑖:𝑦 𝑖=−1(𝑤. 𝑥𝑖))
𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖
f( 𝑥) =(𝑤. 𝑥) - b
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
11
Solve following Question
1. Find the SVM classifier for the following dataset:
Sample F1 F2 Class
1 2 1 +1
2 4 3 -1
Question taken from Dr V N Krishnachandran, Vidya Centre for Artificial Intelligence Research, Vidya Academy of Science &
Technology, Thrissur
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
13
Sample F1 F2 Class
1 2 1 +1
2 4 3 -1
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
N = 2, 𝑥1 = (2,1), 𝑥2 = 4,3 ,𝑦1 = +1, 𝑦2 = −1
(𝛼1+𝛼2) −
1
2
[𝛼1 𝛼1 𝑦1 𝑦1(𝑥1. 𝑥1) + 𝛼1 𝛼2 𝑦1 𝑦2(𝑥1. 𝑥2) + 𝛼2 𝛼1 𝑦2 𝑦1(𝑥2. 𝑥1) + 𝛼2 𝛼2 𝑦2 𝑦2(𝑥2. 𝑥2) ]
(𝛼1+𝛼2) −
1
2
[𝛼1
2(+1)(+1)(2x2 + 1x1) + 𝛼1 𝛼2(+1)(-1)(2x4 + 1x3) + 𝛼2 𝛼1(-1) (+1)(4x2 + 3x1) +
𝛼2
2(-1)(-1)(4x4 + 3x3) ]
α1y1 + α2y2 =0 α1− α2 = 0
Find vector 𝛼 which maximizes 𝛼𝑖 −
1
2
𝛼𝑖 𝛼𝑗 𝑦𝑖 𝑦𝑗 (𝑥𝑖. 𝑥𝑗)
Subject to 𝛼𝑖 𝑦𝑖 = 0
α =(𝛼1, 𝛼2)
(𝛼1+𝛼2) −
1
2
[5𝛼1
2 -22𝛼1 𝛼2 + 25𝛼2
2 ]
14
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
Find values of 𝛼1 and 𝛼2which maximizes ∅(α) = (𝛼1+𝛼2) −
1
2
[5𝛼1
2 -22𝛼1 𝛼2 + 25𝛼2
2 ]
Subject to conditions α1− α2 = 0, 𝛼1 > 0, 𝛼2 > 0
Substituting 2 in 1, ∅(α) = (𝛼1+𝛼1) −
1
2
[5𝛼1
2 -22𝛼1 𝛼1 + 25𝛼1
2 ]
2
1
= (2𝛼1) −
1
2
[8𝛼1
2 ]
2−8𝛼1 = 0For ∅(α) to be maximum
𝑑∅
𝑑𝛼1
= 0 𝛼1 = ¼ 𝛼2 = ¼
Second derivative is –ve so this is maximum
Sample F1 F2 Class
1 2 1 +1
2 4 3 -1
15
Compute 𝑤 and b
𝑏 =
1
2
(𝑚𝑖𝑛𝑖:𝑦 𝑖=+1(𝑤. 𝑥𝑖) + 𝑚𝑎𝑥𝑖:𝑦 𝑖=−1(𝑤. 𝑥𝑖))𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖
𝑤 = 𝛼1 𝑦1 𝑥1 + 𝛼2 𝑦2 𝑥2
=
1
4
+1 2,1 +
1
4
(−1)(4,3)
=
1
4
[ 2,1 + −4, −3 ] =
1
4
[ −2, −2 ] = −
1
2
, −
1
2
𝑏 =
1
2
( (𝑤. 𝑥1) + (𝑤. 𝑥2))
=
1
2
( −
1
2
× 2 −
1
2
× 1 + (−
1
2
× 4 −
1
2
× 3))
Sample F1 F2 Class
1 2 1 +1
2 4 3 -1=
1
2
( −
3
2
+ (−
7
2
)) =
1
2
−
10
2
= −
5
2
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
16
SVM Classifier Function: f( 𝑥) =(𝑤. 𝑥) - b
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
= −
1
2
, −
1
2
. (𝑥1, 𝑥2) +
5
2
= −
1
2
𝑥1 −
1
2
𝑥2 +
5
2
= −
1
2
[𝑥1 + 𝑥2−5]
Equation of maximal margin line
f( 𝑥) = 0 𝑥1 + 𝑥2 = 5
0 1 2 3 4 5 6
1
2
3
4
5
6
Sampl
e
F1 F2 Class
1 2 1 +1
2 4 3 -1
Reference
1. Sudheep Elayidom, M. Data mining and warehousing, Cengage.
2. V. Vapnik, The Nature of Statistical Learning Theory, Springer, 1995
3. Vapnik, V. Statistical Learning Theory. John Wiley & Sons. Inc., New York, 1998
4. B. Schölkopf and A. J. Smola, Learning with Kernels, MIT Press, Cambridge, MA, 2002
5. Davide, M. and Simon, H. Advances in Kernel Methods, 1999, 226-227.
6. Jaiwei Han, Micheline Kamber, “Data Mining Concepts and Techniques”, Elsevier, 2006.
7. Pang-Ning Tan, Michael Steinbach, “Introduction to Data Mining”, Addison Wesley,
2006.
8. Dunham M H, “Data Mining: Introductory and Advanced Topics”, Pearson Education,
New Delhi, 2003.
9. Mehmed Kantardzic, “Data Mining Concepts, Methods and Algorithms”, John Wiley
and Sons, USA, 2003.
Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
17

More Related Content

What's hot

Review Sheet B Substitution And Solving Inequalities
Review Sheet B Substitution And Solving InequalitiesReview Sheet B Substitution And Solving Inequalities
Review Sheet B Substitution And Solving Inequalities
vmonacelli
 
Mat 045 final exam review part i
Mat 045 final exam review   part iMat 045 final exam review   part i
Mat 045 final exam review part i
Mae Guerra
 

What's hot (18)

Simplifying Radicals & Solving Quadratics
Simplifying Radicals & Solving QuadraticsSimplifying Radicals & Solving Quadratics
Simplifying Radicals & Solving Quadratics
 
On Cubic Graceful Labeling
On Cubic Graceful LabelingOn Cubic Graceful Labeling
On Cubic Graceful Labeling
 
Matematik Tambahan Skema set 1
Matematik Tambahan Skema set 1Matematik Tambahan Skema set 1
Matematik Tambahan Skema set 1
 
Al.ex1
Al.ex1Al.ex1
Al.ex1
 
合同数問題と保型形式
合同数問題と保型形式合同数問題と保型形式
合同数問題と保型形式
 
Chapter 2 sequencess and series
Chapter 2 sequencess and seriesChapter 2 sequencess and series
Chapter 2 sequencess and series
 
Al.ex2
Al.ex2Al.ex2
Al.ex2
 
Review Sheet B Substitution And Solving Inequalities
Review Sheet B Substitution And Solving InequalitiesReview Sheet B Substitution And Solving Inequalities
Review Sheet B Substitution And Solving Inequalities
 
Chap 4 complex numbers focus exam ace
Chap 4 complex numbers focus exam aceChap 4 complex numbers focus exam ace
Chap 4 complex numbers focus exam ace
 
Vectors intro
Vectors introVectors intro
Vectors intro
 
More simplifying radicals & solving quadratic equations
More simplifying radicals & solving quadratic equationsMore simplifying radicals & solving quadratic equations
More simplifying radicals & solving quadratic equations
 
Trial terengganu 2014 spm add math k1 skema [scan]
Trial terengganu 2014 spm add math k1 skema [scan]Trial terengganu 2014 spm add math k1 skema [scan]
Trial terengganu 2014 spm add math k1 skema [scan]
 
Mat 045 final exam review part i
Mat 045 final exam review   part iMat 045 final exam review   part i
Mat 045 final exam review part i
 
Tema 26
Tema 26Tema 26
Tema 26
 
IRJET- On the Homogeneous Ternary Quadratic Diophantine Equation 3(X+Y)2-2xy=...
IRJET- On the Homogeneous Ternary Quadratic Diophantine Equation 3(X+Y)2-2xy=...IRJET- On the Homogeneous Ternary Quadratic Diophantine Equation 3(X+Y)2-2xy=...
IRJET- On the Homogeneous Ternary Quadratic Diophantine Equation 3(X+Y)2-2xy=...
 
Practica 1 numeros naturales y enteros
Practica 1 numeros naturales y enterosPractica 1 numeros naturales y enteros
Practica 1 numeros naturales y enteros
 
POTENCIAS Y RADICALES
POTENCIAS Y RADICALESPOTENCIAS Y RADICALES
POTENCIAS Y RADICALES
 
ロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズ
 

Similar to Support Vector Machines

Similar to Support Vector Machines (20)

Svm soft margin hyperplanes
Svm   soft margin hyperplanesSvm   soft margin hyperplanes
Svm soft margin hyperplanes
 
12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1 12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1
 
Mte (1)
Mte (1)Mte (1)
Mte (1)
 
Trabajo matemáticas 7
Trabajo matemáticas 7Trabajo matemáticas 7
Trabajo matemáticas 7
 
FUNCTIONS L.1.pdf
FUNCTIONS L.1.pdfFUNCTIONS L.1.pdf
FUNCTIONS L.1.pdf
 
Z transforms
Z transformsZ transforms
Z transforms
 
1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros
 
Pre-calculus 1, 2 and Calculus I (exam notes)
Pre-calculus 1, 2 and Calculus I (exam notes)Pre-calculus 1, 2 and Calculus I (exam notes)
Pre-calculus 1, 2 and Calculus I (exam notes)
 
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
 
Sol mat haeussler_by_priale
Sol mat haeussler_by_prialeSol mat haeussler_by_priale
Sol mat haeussler_by_priale
 
31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual
 
Solucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economiaSolucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economia
 
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine TransformRadix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
 
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine TransformRadix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
 
Tugas Kalkulus
Tugas KalkulusTugas Kalkulus
Tugas Kalkulus
 
Tugas Kalkulus Diferentiation
Tugas Kalkulus DiferentiationTugas Kalkulus Diferentiation
Tugas Kalkulus Diferentiation
 
Tugas kalkulus
Tugas kalkulusTugas kalkulus
Tugas kalkulus
 
Banco de preguntas para el ap
Banco de preguntas para el apBanco de preguntas para el ap
Banco de preguntas para el ap
 
Raices de un polinomio 11
Raices de un polinomio 11Raices de un polinomio 11
Raices de un polinomio 11
 
Tarea 1 vectores, matrices y determinantes laura montes
Tarea 1   vectores, matrices y determinantes laura montesTarea 1   vectores, matrices y determinantes laura montes
Tarea 1 vectores, matrices y determinantes laura montes
 

Recently uploaded

+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Support Vector Machines

  • 1. SUPPORT VECTOR MACHINES Sarith Divakar M LBS College of Engineering, Kasaragod sarith@lbscek.ac.in
  • 2. Support Vector Machines Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 2
  • 3. Decision Boundary Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 3
  • 4. Decision Rule 𝑤 𝑢 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 4 𝑤. 𝑢 ≥ C, Then +ve 𝐶 = −𝑏𝑤. 𝑢 + b ≥ 0, Then +ve
  • 5. Constraint 𝑤 𝑢 𝑤. 𝑥+ + b ≥ 1 1 𝑤. 𝑥− + b ≤ -1 2 𝑦𝑖(𝑤. 𝑥𝑖 + b) ≥ 1 𝑦𝑖 = 1 for Positive Samples 𝑦𝑖 = -1 for Negative Samples 𝑦𝑖(𝑤. 𝑥𝑖 + b) ≥ 1 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 ≥ 0 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 for 𝑥𝑖 in the gutter Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 5
  • 6. Width of the street 𝑊𝑖𝑑𝑡ℎ = (𝑥+ - 𝑥− ) . 𝑤 ||𝑤|| For +ve samples 𝑦𝑖=1 and –ve samples 𝑦𝑖 = -1 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 3 1.(𝑤. 𝑥𝑖 + b) −1 = 0 𝑤. 𝑥𝑖 = 1-b i -1.(𝑤. 𝑥𝑖 + b) −1 = 0 𝑤. 𝑥𝑖 = -1-b ii 𝑊𝑖𝑑𝑡ℎ = (1-b – (-1-b)) . 1 ||𝑤|| 𝑥+ 𝑥− 𝑥+ - 𝑥− 𝑊𝑖𝑑𝑡ℎ = 2 ||𝑤|| Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 6
  • 7. Maximize Width of the street 𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 = 2 ||𝑤|| 𝑥+ 𝑥− 𝑥+ + 𝑥− 𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 = 1 ||𝑤|| 𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 = ||𝑤|| 𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 = 1 2 ||𝑤|| 2 4 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 7
  • 8. Optimization using Lagrange multipliers Expression: 𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 = 1 2 ||𝑤|| 2 Constraint: 𝑦𝑖(𝑤. 𝑥𝑖 + b) −1 = 0 L= 1 2 ||𝑤|| 2 - 𝛼𝑖 [𝑦𝑖(𝑤. 𝑥𝑖 + b) − 1] 𝜕𝐿 𝜕𝑤 = 𝑤- 𝛼𝑖 𝑦𝑖 𝑥𝑖 = 0 𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖 6 𝜕𝐿 𝜕𝑏 = - 𝛼𝑖 𝑦𝑖 = 0 𝛼𝑖 𝑦𝑖 = 0 7 5 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 8
  • 9. Optimization using Lagrange multipliers 7 L= 1 2 ||𝑤|| 2 - 𝛼𝑖 [𝑦𝑖(𝑤. 𝑥𝑖 + b) − 1] 𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖 5 6 𝛼𝑖 𝑦𝑖 = 0 L= 1 2 ( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- 𝛼𝑖 [𝑦𝑖(( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )𝑥𝑖 + b) − 1] L= 1 2 ( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- ( 𝛼𝑖 𝑦𝑖 𝑥𝑖). ( 𝛼𝑗 𝑦𝑗 𝑥𝑗) − 𝛼𝑖 𝑦𝑖 b + 𝛼𝑖 = 0 L= 𝛼𝑖 + 1 2 ( 𝛼𝑖 𝑦𝑖 𝑥𝑖 ).( 𝛼𝑗 𝑦𝑗 𝑥𝑗 )- ( 𝛼𝑖 𝑦𝑖 𝑥𝑖). ( 𝛼𝑗 𝑦𝑗 𝑥𝑗) L= 𝛼𝑖 − 1 2 𝛼𝑖 𝑦𝑖 𝛼𝑗 𝑦𝑗 (𝑥𝑖. 𝑥𝑗) Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 9
  • 10. Decision Rule f(𝑢) = 𝛼𝑖 𝑦𝑖(𝑥𝑖 . 𝑢) - b ? Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 10
  • 11. SVM Classifier L= 𝛼𝑖 − 1 2 𝛼𝑖 𝑦𝑖 𝛼𝑗 𝑦𝑗 (𝑥𝑖. 𝑥𝑗) Compute 𝑤 and b Find vector 𝛼 which maximizes Subject to 𝛼𝑖 𝑦𝑖 = 0 SVM Classifier Function: 𝑏 = 1 2 (𝑚𝑖𝑛𝑖:𝑦 𝑖=+1(𝑤. 𝑥𝑖) + 𝑚𝑎𝑥𝑖:𝑦 𝑖=−1(𝑤. 𝑥𝑖)) 𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖 f( 𝑥) =(𝑤. 𝑥) - b Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 11
  • 12. Solve following Question 1. Find the SVM classifier for the following dataset: Sample F1 F2 Class 1 2 1 +1 2 4 3 -1 Question taken from Dr V N Krishnachandran, Vidya Centre for Artificial Intelligence Research, Vidya Academy of Science & Technology, Thrissur Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
  • 13. 13 Sample F1 F2 Class 1 2 1 +1 2 4 3 -1 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod N = 2, 𝑥1 = (2,1), 𝑥2 = 4,3 ,𝑦1 = +1, 𝑦2 = −1 (𝛼1+𝛼2) − 1 2 [𝛼1 𝛼1 𝑦1 𝑦1(𝑥1. 𝑥1) + 𝛼1 𝛼2 𝑦1 𝑦2(𝑥1. 𝑥2) + 𝛼2 𝛼1 𝑦2 𝑦1(𝑥2. 𝑥1) + 𝛼2 𝛼2 𝑦2 𝑦2(𝑥2. 𝑥2) ] (𝛼1+𝛼2) − 1 2 [𝛼1 2(+1)(+1)(2x2 + 1x1) + 𝛼1 𝛼2(+1)(-1)(2x4 + 1x3) + 𝛼2 𝛼1(-1) (+1)(4x2 + 3x1) + 𝛼2 2(-1)(-1)(4x4 + 3x3) ] α1y1 + α2y2 =0 α1− α2 = 0 Find vector 𝛼 which maximizes 𝛼𝑖 − 1 2 𝛼𝑖 𝛼𝑗 𝑦𝑖 𝑦𝑗 (𝑥𝑖. 𝑥𝑗) Subject to 𝛼𝑖 𝑦𝑖 = 0 α =(𝛼1, 𝛼2) (𝛼1+𝛼2) − 1 2 [5𝛼1 2 -22𝛼1 𝛼2 + 25𝛼2 2 ]
  • 14. 14 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod Find values of 𝛼1 and 𝛼2which maximizes ∅(α) = (𝛼1+𝛼2) − 1 2 [5𝛼1 2 -22𝛼1 𝛼2 + 25𝛼2 2 ] Subject to conditions α1− α2 = 0, 𝛼1 > 0, 𝛼2 > 0 Substituting 2 in 1, ∅(α) = (𝛼1+𝛼1) − 1 2 [5𝛼1 2 -22𝛼1 𝛼1 + 25𝛼1 2 ] 2 1 = (2𝛼1) − 1 2 [8𝛼1 2 ] 2−8𝛼1 = 0For ∅(α) to be maximum 𝑑∅ 𝑑𝛼1 = 0 𝛼1 = ¼ 𝛼2 = ¼ Second derivative is –ve so this is maximum Sample F1 F2 Class 1 2 1 +1 2 4 3 -1
  • 15. 15 Compute 𝑤 and b 𝑏 = 1 2 (𝑚𝑖𝑛𝑖:𝑦 𝑖=+1(𝑤. 𝑥𝑖) + 𝑚𝑎𝑥𝑖:𝑦 𝑖=−1(𝑤. 𝑥𝑖))𝑤 = 𝛼𝑖 𝑦𝑖 𝑥𝑖 𝑤 = 𝛼1 𝑦1 𝑥1 + 𝛼2 𝑦2 𝑥2 = 1 4 +1 2,1 + 1 4 (−1)(4,3) = 1 4 [ 2,1 + −4, −3 ] = 1 4 [ −2, −2 ] = − 1 2 , − 1 2 𝑏 = 1 2 ( (𝑤. 𝑥1) + (𝑤. 𝑥2)) = 1 2 ( − 1 2 × 2 − 1 2 × 1 + (− 1 2 × 4 − 1 2 × 3)) Sample F1 F2 Class 1 2 1 +1 2 4 3 -1= 1 2 ( − 3 2 + (− 7 2 )) = 1 2 − 10 2 = − 5 2 Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod
  • 16. 16 SVM Classifier Function: f( 𝑥) =(𝑤. 𝑥) - b Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod = − 1 2 , − 1 2 . (𝑥1, 𝑥2) + 5 2 = − 1 2 𝑥1 − 1 2 𝑥2 + 5 2 = − 1 2 [𝑥1 + 𝑥2−5] Equation of maximal margin line f( 𝑥) = 0 𝑥1 + 𝑥2 = 5 0 1 2 3 4 5 6 1 2 3 4 5 6 Sampl e F1 F2 Class 1 2 1 +1 2 4 3 -1
  • 17. Reference 1. Sudheep Elayidom, M. Data mining and warehousing, Cengage. 2. V. Vapnik, The Nature of Statistical Learning Theory, Springer, 1995 3. Vapnik, V. Statistical Learning Theory. John Wiley & Sons. Inc., New York, 1998 4. B. Schölkopf and A. J. Smola, Learning with Kernels, MIT Press, Cambridge, MA, 2002 5. Davide, M. and Simon, H. Advances in Kernel Methods, 1999, 226-227. 6. Jaiwei Han, Micheline Kamber, “Data Mining Concepts and Techniques”, Elsevier, 2006. 7. Pang-Ning Tan, Michael Steinbach, “Introduction to Data Mining”, Addison Wesley, 2006. 8. Dunham M H, “Data Mining: Introductory and Advanced Topics”, Pearson Education, New Delhi, 2003. 9. Mehmed Kantardzic, “Data Mining Concepts, Methods and Algorithms”, John Wiley and Sons, USA, 2003. Department of Computer Science and Engineering, LBS College of Engineering, Kasaragod 17