All Courses

An Introduction to Support Vector Machines

Anmol Sharma

2 years ago

An Introduction to Support Vector Machines | insideAIML
Table of Content
  • Introduction
  • What is Support Vector Machines Algorithm?
  • Python Implementation of Support Vector Machine
  • Advantages of SVM
  • Disadvantages of SVM
  • Summary

Introduction

          Is there any supervised learning algorithm that solves both regression and classification problems efficiently? Yes, there is and that algorithm is Support Vector Machines. SVM or Support Vector Machines is one of the finest machine learning algorithms that work well on both regression and classification problems. In this article, we will learn Support Vector Machines in machine learning from scratch and also implement it using Python. So, let’s understand this beautiful algorithm.

What is Support Vector Machines Algorithm?

          SVM is one of the best supervised learning algorithms that can be used for both regression and classification problems. It is generally used for classification purposes and it yields better results than other classifiers such as decision trees and logistic regression algorithm.
It generates hyperplanes to classify data points into different categories. The hyperplane that separates the data points of different classes most accurately is finalized and used for classification. 
Take a look at the picture below.
Support Vector Machines | insideAIML
The terms in the above image are described below.
  • Hyperplane - A decision plane that separates data points of different classes.
  • Support Vector - The data points nearest to the hyperplane.
  • Margin - The gap between two lines on the closest class point.
SVM can handle both linear and non-linear data. The working of SVM for both cases is described below:

Working of SVM

Case 1: Linear Data

  • Generate hyperplanes that separate the data points into different classes in the best possible way. 
Linear Data | insideAIML
  • Among the hyperplanes generated select the hyperplane which segregates datapoint most efficiently i.e maximum datapoints of similar classes are on the same side and those of different classes on the other side.
Linear Data | insideAIML

Case 2: Non-linear Data

  • Use the kernel trick, transform the input space to a higher-dimensional space.
  • Then separate the points using linear separation.
Non-linear Data | insideAIML

Python Implementation of Support Vector Machines

SVM can be implemented using the scikit-learn library in Python. Below is the code.
from sklearn import SVM

clf = SVM.SVC()         #for classification

reg = SVM.SVR()  	   #for regression

clf.fit(training_data, training_label)

predict_value = clf.predict(test_data)

predict_value = clf.score(test_label, predict_value)
Similarly, you can build the SVM classifier model in Python. 

Advantages of SVM

  • It works well for problems with non-linear data.
  • Efficient for high dimension problems.
  • Have high accuracy in comparison to other classifiers and regressors like logistic regression algorithm and polynomial regression.
  • Memory efficient.

Disadvantages of SVM

  • Not work well on large datasets.
  • Sensitive to noise.
  • Time taking.

Summary

         Support Vector Machines is a top-notch machine learning algorithm that easily handles both regression and classification problems and yields better results than other algorithms. In this article, we learned about Support Vector Machines(SVM) in machine learning, discovered how it can deal with both linear and non-linear data, how it works, implemented it using Python’s scikit learn library and mentioned its advantages and disadvantages. We discovered that SVM is better than other classification and regression algorithms like logistic regression algorithm, polynomial regression and decision trees. 
We hope you gain an understanding of Support vector machines in machine learning. Do reach out to us for queries on our, AI-dedicated discussion forum and get your query resolved within 30 minutes.
     
Like the Blog, then Share it with your friends and colleagues to make this AI community stronger. 
To learn more about nuances of Artificial Intelligence, Python Programming, Deep Learning, Data Science and Machine Learning, visit our blog page.
Keep Learning. Keep Growing. 
     

Submit Review