Supervised Learning — Support Vector Machine

Supervised Learning — Support Vector Machine

This article breaks down the topic of support vector machines deductively, covering the most basic approach to the underlying mathematics. The information is supported by examples and aims to create their own approaches to the subject, regardless of their level of knowledge.

This article breaks down the topic of support vector machines deductively, covering the most basic approach to the underlying mathematics. The information is supported by examples and aims to create their own approaches to the subject, regardless of their level of knowledge.

Table of Contents (TOC)
1\. Introduction
2\. Kernelized Support Vector Machines
2.1\. Linear Model
2.2\. Polynomial Kernel
2.3\. Gaussian RBF Kernel
3\. Hyperparameters
4\. Under the Hood

1. Introduction

Support Vector Machines are powerful and versatile machine learning algorithms that can be used for both classification and regression. The usage area of these algorithms is quite wide. It is dynamically developed and used in many fields from images classification to medical image cancer diagnosis, from text data to bioinformatics. Since we’re going to take the whole thing and break it down, let’s first illustrate the instinctive basic working of support vector machines.

Let’s create a dataset with 2 inputs (x1 and x2) and 2 outputs (purple and red) as seen in figure 1(left). The goal of the model is to predict the class of data which is given x1 and x2 values after the model is trained. In other words, model should distinguish the dataset in the most optimal way. Purple and red data can be linearly separated by an infinite number of linear lines as seen in figure 1(middle). Looking at these lines, it is realized that none of these infinitely drawn points are related to the number or density of data in the dataset. These reference points are called support vectors (Figure 1. right). Support vectors are the data which are closest the hyperplane. Now, let’s quickly separate the make_blob dataset with 100 data and 2 classes, which we imported with the scikit learn library, with the support vector machine.

import mglearn
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
import numpy as np
IN[1]
x, y = make_blobs(n_samples=100, centers=4, cluster_std=0.8, random_state=8)
y=y%2
IN[2]
mglearn.discrete_scatter(x[:, 0], x[:, 1], y)
IN[3]
from sklearn.svm import LinearSVC
linear_svm = LinearSVC().fit(x, y)
mglearn.plots.plot_2d_separator(linear_svm, x)
mglearn.discrete_scatter(x[:, 0], x[:, 1], y)
plt.xlabel("Feature 0")
plt.ylabel("Feature 1")
IN[4]
from sklearn.svm import SVC
svm = SVC(kernel='rbf').fit(x, y)
mglearn.plots.plot_2d_separator(svm, x)
mglearn.discrete_scatter(x[:, 0], x[:, 1], y)
plt.xlabel("Feature 0")
plt.ylabel("Feature 1")

It can be seen both in the accuracy of the test data and visually that Linear SVM separates classes worse than the Radial Basis Function (RBF) Kernel. Now let’s examine the kernel types in the Support Vector Machines one by one.

supervised-learning artificial-intelligence data-science machine-learning

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Deep Learning vs Machine Learning vs Artificial Intelligence vs Data Science

This "Deep Learning vs Machine Learning vs AI vs Data Science" video talks about the differences and relationship between Artificial Intelligence, Machine Learning, Deep Learning, and Data Science.

The Difference between Data Science, Machine Learning and Big Data!

Many professionals and 'Data' enthusiasts often ask, “What's the difference between Data Science, Machine Learning and Big Data?”. Let's clear the air. If you are still wondering about it then this article is for you.

Most popular Data Science and Machine Learning courses — July 2020

Most popular Data Science and Machine Learning courses — August 2020. This list was last updated in August 2020 — and will be updated regularly so as to keep it relevant

How I'd Learn Data Science If I Were To Start All Over Again

A couple of days ago I started thinking if I had to start learning machine learning and data science all over again where would I start?

Start a Career in Machine Learning and Artificial Intelligence

Enroll now at best Artificial Intelligence training in Noida, - the best Institute in India for Artificial Intelligence Online Training Course and Certification.