Pca PDF
Pca PDF
Machine
Support Vectors are simply the co-ordinates of individual observation. Support Vector
Machine is a frontier which best segregates the two classes (hyper-plane/ line).
You can look at support vector machines and a few examples of its working here.
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!
Let’s understand:
• 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.
Above, you can see that the margin for hyper-plane C is high as compared to
both A and B. Hence, we name the right hyper-plane as C. Another lightning
reason for selecting the hyper-plane with higher margin is robustness. If we
select a hyper-plane having low margin then there is high chance of miss-
classification.
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.
o All values for z would be positive always because z is the squared sum of
both x and y
o In the original plot, red circles appear close to the origin of x and y axes,
leading to lower value of z and star relatively away from the origin result
to higher value of z.
In SVM, it is easy to have a linear hyper-plane between these two classes. But,
another burning question which arises is, should we need to add this feature
manually to have a hyper-plane. No, SVM has a technique called the kernel
trick. These are functions which takes low dimensional input space and
transform it to a higher dimensional space i.e. it converts not separable
problem to separable problem, these functions are called kernels. It is mostly
useful in non-linear separation problem. Simply put, it does some extremely
complex data transformations, then find out the process to separate the data
based on the labels or outputs you’ve defined.
When we look at the hyper-plane in original input space it looks like a circle:
How to implement SVM in R?
#Import Library
# there are various options associated with SVM training; like changing kernel, ga
# create model
mma=0.2,cost=100)
#Predict Output
table(preds)
How to tune Parameters of SVM?
Tuning parameters value for machine learning algorithms effectively improves the
model performance.
kernel: We have already discussed about it. Here, we have various options available
with kernel like, “linear”, “rbf”,”poly” and others (default value is “rbf”). Here “rbf”
and “poly” are useful for non-linear hyper-plane.
Gamma:The gamma parameter defines how far the influence of a single training
example reaches, with low values meaning ‘far’ and high values meaning ‘close’. In
other words, with low gamma, points far away from plausible seperation line are
considered in calculation for the seperation line. Where as high gamma means the
points close to plausible line are considered in calculation.
Margin:A margin is a separation of line to the closest class points. A good margin is
one where this separation is larger for both the classes.
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.