SlideShare a Scribd company logo
1 of 21
SupportVector
Machines (SVM)
Muhammad Haroon
Lecturer, University of Gujrat Lahore Sub Campus
Introduction
 “SupportVector Machine” (SVM) is mostly
used in classification problems. In this
algorithm, we plot each data item as a point in
n-dimensional space (where n is number of
features you have) with the value of each
feature being the value of a particular
coordinate.
How does it
work?
 Above, we got accustomed to the process
of segregating the two classes with a hyper-
plane. Now the burning question is “How can
we identify the right hyper-plane?”. Don’t
worry, it’s not as hard as you think!
Scenario 1
Here, we have three hyper-planes (A, B and C). Now,
identify the right hyper-plane to classify star and circle.
You need to remember a thumb rule to identify the right
hyper-plane: “Select the hyper-plane which segregates
the two classes better”. In this scenario, hyper-plane “B”
has excellently performed this job.
Scenario 2
 Here, we have three hyper-planes (A, B and C) and all
are segregating the classes well. Now, How can we
identify the right hyper-plane?
 Here, maximizing the distances between nearest data
point (either class) and hyper-plane will help us to
decide the right hyper-plane.This distance is called
as Margin. Let’s look at the below snapshot:
Scenario 3
 Some of you may have selected the hyper-plane B as it
has higher margin compared to A. But, here is
the catch, SVM selects the hyper-plane which classifies
the classes accurately prior to maximizing margin.
Here, hyper-plane B has a classification error and A has
classified all correctly.Therefore, the right hyper-plane
is A.
Can we classify
two
classes (Scenari
o-4)?
 Below, I am unable to segregate the two classes using a
straight line, as one of star lies in the territory of
other(circle) class as an outlier.

Find the
hyper-plane
to segregate
to classes
(Scenario-5):
 In the scenario below, we can’t have linear hyper-plane
between the two classes, so how does SVM classify
these two classes?Till now, we have only looked at the
linear hyper-plane.
 SVM can solve this problem. Easily! It solves this
problem by introducing additional feature. Here, we
will add a new feature z=x^2+y^2. Now, let’s plot the
data points on axis x and z:
PROS
 It works really well with clear margin of
separation
 It is effective in high dimensional spaces.
 It is effective in cases where number of
dimensions is greater than the number of
samples.
 It uses a subset of training points in the
decision function (called support vectors), so it
is also memory efficient.
CONS
 It doesn’t perform well, when we have large
data set because the required training time is
higher
 It also doesn’t perform very well, when the data
set has more noise i.e. target classes are
overlapping
 SVM doesn’t directly provide probability
estimates, these are calculated using an
expensive five-fold cross-validation. It is related
SVC method of Python scikit-learn library.
Cost Function
 In the SVM algorithm, we are looking to maximize the margin
between the data points and the hyperplane.The loss function
that helps maximize the margin is hinge loss.
KERNEL
 AKernel is a “similarity function” that we
provide to a machine learning algorithm,
most commonly, an SVM. It takes two inputs
and outputs how similar they are. The means
by which this similarity is determined
differentiates one kernel function from
another. It is a shortcut that helps us do
certain calculation faster which otherwise
would involve computations in higher
dimensional space
 We have 2 colours of balls on the table that we want to
separate.
We get a stick and put it on the table, this work. Pretty
well right?
Somevillain comes and places more balls on the table, it
kind of works but one of the balls is on the wrong side
and there is probably abetter place toput the stick
now.
SVMs try to put the stick in the best possible place by
having asbig agap on either side of the stickas
possible.
 There is another trick in the SVMtoolbox thatis even
more important. Saythe villain has seen how good
you are with astick so he gives you anew challenge.
There’s no stick in the world that will let you split those
balls well, so what do you do? Youflipthe table of
course! Throwing the balls into the air. Then, with your
pro ninja skills, you grab asheet ofpaper and slip it
between theballs.
.
“The ballscanbeconsideredasdata,the stick
aclassifier, the biggestgaptrick an
optimization, flipping the table kernelling
andthe pieceof paperahyperplane”

More Related Content

Similar to Support vector machines (svm)

Similar to Support vector machines (svm) (20)

sentiment analysis using support vector machine
sentiment analysis using support vector machinesentiment analysis using support vector machine
sentiment analysis using support vector machine
 
Support Vector Machines USING MACHINE LEARNING HOW IT WORKS
Support Vector Machines USING MACHINE LEARNING HOW IT WORKSSupport Vector Machines USING MACHINE LEARNING HOW IT WORKS
Support Vector Machines USING MACHINE LEARNING HOW IT WORKS
 
Classification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptxClassification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptx
 
Support Vector Machine topic of machine learning.pptx
Support Vector Machine topic of machine learning.pptxSupport Vector Machine topic of machine learning.pptx
Support Vector Machine topic of machine learning.pptx
 
Machine Learning using Support Vector Machine
Machine Learning using Support Vector MachineMachine Learning using Support Vector Machine
Machine Learning using Support Vector Machine
 
SVM & KNN Presentation.pptx
SVM & KNN Presentation.pptxSVM & KNN Presentation.pptx
SVM & KNN Presentation.pptx
 
lec10svm.ppt
lec10svm.pptlec10svm.ppt
lec10svm.ppt
 
classification algorithms in machine learning.pptx
classification algorithms in machine learning.pptxclassification algorithms in machine learning.pptx
classification algorithms in machine learning.pptx
 
Support vector machine-SVM's
Support vector machine-SVM'sSupport vector machine-SVM's
Support vector machine-SVM's
 
properties, application and issues of support vector machine
properties, application and issues of support vector machineproperties, application and issues of support vector machine
properties, application and issues of support vector machine
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
 
svm.pptx
svm.pptxsvm.pptx
svm.pptx
 
lec10svm.ppt
lec10svm.pptlec10svm.ppt
lec10svm.ppt
 
Svm ms
Svm msSvm ms
Svm ms
 
lec10svm.ppt
lec10svm.pptlec10svm.ppt
lec10svm.ppt
 
Support vector machines
Support vector machinesSupport vector machines
Support vector machines
 
Support vector machine
Support vector machineSupport vector machine
Support vector machine
 
Support Vector Machine.pptx
Support Vector Machine.pptxSupport Vector Machine.pptx
Support Vector Machine.pptx
 
Support Vector Machines- SVM
Support Vector Machines- SVMSupport Vector Machines- SVM
Support Vector Machines- SVM
 
PRML Chapter 4
PRML Chapter 4PRML Chapter 4
PRML Chapter 4
 

More from Muhammad Haroon

More from Muhammad Haroon (20)

Basic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler ConstructionBasic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler Construction
 
Address in the target code in Compiler Construction
Address in the target code in Compiler ConstructionAddress in the target code in Compiler Construction
Address in the target code in Compiler Construction
 
Code generator in Compiler Construction
Code generator in Compiler ConstructionCode generator in Compiler Construction
Code generator in Compiler Construction
 
Target language in compiler design
Target language in compiler designTarget language in compiler design
Target language in compiler design
 
Heap management in Compiler Construction
Heap management in Compiler ConstructionHeap management in Compiler Construction
Heap management in Compiler Construction
 
Storage organization and stack allocation of space
Storage organization and stack allocation of spaceStorage organization and stack allocation of space
Storage organization and stack allocation of space
 
Backpatching in Compiler Construction
Backpatching in Compiler ConstructionBackpatching in Compiler Construction
Backpatching in Compiler Construction
 
Type checking in Compiler Construction
Type checking in Compiler ConstructionType checking in Compiler Construction
Type checking in Compiler Construction
 
Type conversion in Compiler Construction
Type conversion in Compiler ConstructionType conversion in Compiler Construction
Type conversion in Compiler Construction
 
Semantic analysis in Compiler Construction
Semantic analysis in Compiler ConstructionSemantic analysis in Compiler Construction
Semantic analysis in Compiler Construction
 
Intermediate code and three address instructions
Intermediate code and three address instructionsIntermediate code and three address instructions
Intermediate code and three address instructions
 
LALR(1) parser
LALR(1) parserLALR(1) parser
LALR(1) parser
 
LR(0) parser in Compiler Consturction
LR(0) parser in Compiler ConsturctionLR(0) parser in Compiler Consturction
LR(0) parser in Compiler Consturction
 
SLR(1) parser
SLR(1) parserSLR(1) parser
SLR(1) parser
 
LR(1) CLR(1) Parser with Example
LR(1) CLR(1) Parser with ExampleLR(1) CLR(1) Parser with Example
LR(1) CLR(1) Parser with Example
 
Powerful presentation components and skills
Powerful presentation components and skillsPowerful presentation components and skills
Powerful presentation components and skills
 
Terms of reference in Professional Practices
Terms of reference in Professional PracticesTerms of reference in Professional Practices
Terms of reference in Professional Practices
 
Code of conduct .
Code of conduct .Code of conduct .
Code of conduct .
 
Misuse of computer
Misuse of computerMisuse of computer
Misuse of computer
 
7 habits of highly effective people
7 habits of highly effective people7 habits of highly effective people
7 habits of highly effective people
 

Recently uploaded

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

Support vector machines (svm)

  • 1. SupportVector Machines (SVM) Muhammad Haroon Lecturer, University of Gujrat Lahore Sub Campus
  • 2. Introduction  “SupportVector Machine” (SVM) is mostly used in classification problems. In this algorithm, we plot each data item as a point in n-dimensional space (where n is number of features you have) with the value of each feature being the value of a particular coordinate.
  • 3.
  • 4. How does it work?  Above, we got accustomed to the process of segregating the two classes with a hyper- plane. Now the burning question is “How can we identify the right hyper-plane?”. Don’t worry, it’s not as hard as you think!
  • 5. Scenario 1 Here, we have three hyper-planes (A, B and C). Now, identify the right hyper-plane to classify star and circle. You need to remember a thumb rule to identify the right hyper-plane: “Select the hyper-plane which segregates the two classes better”. In this scenario, hyper-plane “B” has excellently performed this job.
  • 6. Scenario 2  Here, we have three hyper-planes (A, B and C) and all are segregating the classes well. Now, How can we identify the right hyper-plane?  Here, maximizing the distances between nearest data point (either class) and hyper-plane will help us to decide the right hyper-plane.This distance is called as Margin. Let’s look at the below snapshot:
  • 7. Scenario 3  Some of you may have selected the hyper-plane B as it has higher margin compared to A. But, here is the catch, SVM selects the hyper-plane which classifies the classes accurately prior to maximizing margin. Here, hyper-plane B has a classification error and A has classified all correctly.Therefore, the right hyper-plane is A.
  • 8. Can we classify two classes (Scenari o-4)?  Below, I am unable to segregate the two classes using a straight line, as one of star lies in the territory of other(circle) class as an outlier. 
  • 9. Find the hyper-plane to segregate to classes (Scenario-5):  In the scenario below, we can’t have linear hyper-plane between the two classes, so how does SVM classify these two classes?Till now, we have only looked at the linear hyper-plane.
  • 10.  SVM can solve this problem. Easily! It solves this problem by introducing additional feature. Here, we will add a new feature z=x^2+y^2. Now, let’s plot the data points on axis x and z:
  • 11. PROS  It works really well with clear margin of separation  It is effective in high dimensional spaces.  It is effective in cases where number of dimensions is greater than the number of samples.  It uses a subset of training points in the decision function (called support vectors), so it is also memory efficient.
  • 12. CONS  It doesn’t perform well, when we have large data set because the required training time is higher  It also doesn’t perform very well, when the data set has more noise i.e. target classes are overlapping  SVM doesn’t directly provide probability estimates, these are calculated using an expensive five-fold cross-validation. It is related SVC method of Python scikit-learn library.
  • 13. Cost Function  In the SVM algorithm, we are looking to maximize the margin between the data points and the hyperplane.The loss function that helps maximize the margin is hinge loss.
  • 14. KERNEL  AKernel is a “similarity function” that we provide to a machine learning algorithm, most commonly, an SVM. It takes two inputs and outputs how similar they are. The means by which this similarity is determined differentiates one kernel function from another. It is a shortcut that helps us do certain calculation faster which otherwise would involve computations in higher dimensional space
  • 15.  We have 2 colours of balls on the table that we want to separate.
  • 16. We get a stick and put it on the table, this work. Pretty well right?
  • 17. Somevillain comes and places more balls on the table, it kind of works but one of the balls is on the wrong side and there is probably abetter place toput the stick now.
  • 18. SVMs try to put the stick in the best possible place by having asbig agap on either side of the stickas possible.
  • 19.  There is another trick in the SVMtoolbox thatis even more important. Saythe villain has seen how good you are with astick so he gives you anew challenge.
  • 20. There’s no stick in the world that will let you split those balls well, so what do you do? Youflipthe table of course! Throwing the balls into the air. Then, with your pro ninja skills, you grab asheet ofpaper and slip it between theballs. .
  • 21. “The ballscanbeconsideredasdata,the stick aclassifier, the biggestgaptrick an optimization, flipping the table kernelling andthe pieceof paperahyperplane”