Professional Documents
Culture Documents
Unit No. 2
Supervised learning Part-1
Lecture No. 19
Support Vector Regression
Mr. Praveen
Gupta
Assistant Professor,
CSA/SOET
Outlines
• Support Vector Machine
• Support Vector Regression
• How Support Vector Regression
• Implementation of Support Vector Regression using Python
• References
Student Effective Learning Outcomes(SELO)
01: Ability to understand subject related concepts clearly along with
contemporary issues.
02: Ability to use updated tools, techniques and skills for effective domain
specific practices.
03: Understanding available tools and products and ability to use it effectively.
Support Vector Machine
•“Support Vector Machine” (SVM) is a
supervised machine learning algorithm that can be
used for both classification or regression challenges.
However, it is mostly used in classification
problems.
•In the SVM algorithm, we plot each data item as a
point in n-dimensional space (where n is a number
of features you have) with the value of each feature
being the value of a particular coordinate.
•Then, we perform classification by finding the
hyper-plane that differentiates the two classes very
well.
4 / 22
Support Vector Machine
4 / 22
Hyperparameters of the Support Vector Machine
• Hyperplane: This is basically a separating line
between two data classes in SVM. But in Support
Vector Regression, this is the line that will be used
to predict the continuous output.
• Decision Boundary: A decision boundary can be
thought of as a demarcation line (for simplification)
on one side of which lie positive examples and on
the other side lie the negative examples.
• On this very line, the examples may be classified as
either positive or negative. This same concept of
SVM will be applied in Support Vector Regression as
well.
4 / 22
Support Vector Regression
•When the support vector machine is
used for classification, it is referred to as
support vector classification, and when
it is used for regression, it is referred to
as support vector regression.
•Support Vector regression is a type of
Support vector machine that supports
linear and non-linear regression.
4 / 22
How SVR Works
4 / 22
How SVR Works
4 / 22
How SVR Works
•Consider decision boundary (the danger red line
above!) lines as being at any distance, say ‘a’, from the
hyperplane. So, these are the lines that we draw at
distance ‘+a’ and ‘-a’ from the hyperplane.
• Assuming that the equation of the hyperplane is as
follows: Y = wx+b
• Then the equations of decision boundary become:
wx+b= +a
wx+b= -a
•Thus, any hyperplane that satisfies our SVR should
satisfy: -a < Y- wx+b < +a
4 / 22
How SVR Works
4 / 22
Implementation of SVR using Python
Problem Description:
we have to predict the salary of an employee given a few
independent variables.
4 / 22
Implementation of SVR using Python
4 / 22
Implementation of SVR using Python
4 / 22
Implementation of SVR using Python
4 / 22
Implementation of SVR using Python
4 / 22
Implementation of SVR using Python
4 / 22
Implementation of SVR using Python
Step 6. Visualizing the SVR results (for higher resolution
and smoother curve)
X_grid = np.arange(min(X), max(X), 0.01) #this step required
because data is feature scaled.
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(X, y, color = 'red')
plt.plot(X_grid, regressor.predict(X_grid), color = 'blue')
plt.title('Truth or Bluff (SVR)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()
4 / 22
Implementation of SVR using Python
4 / 22
Learning Outcomes