Home Support Vector for Regression (SVR)
Post
Cancel

Support Vector for Regression (SVR)

What is SVR?

Unlike simple linear regression, you can see a tube instead of a simple line, with a regression line inside the tube.
The tube is called the “epsilon-insensitive tube” and has a width of epsilon.

Any points in the dataset that are inside the tube will have their error disregarded. In short, think of the tube as the margin of error the model can have, and don’t care about the error inside the tube.

These points are treated as errors, measured as the distance between each point and the tube. These distances have names, as shown in the image below.


Using these distances, we can derive the following formula:

Example



Code



1
2
3
4
5
6
from sklearn.svm import SVR
regressor = SVR(kernel='rbf')#rbf = function to use as kernel in svm
sc_y = StandardScaler()
y = sc_y.fit_transform(y)
regressor.fit(X, y)
sc_y.inverse_transform(regressor.predict(X).reshape(-1, 1))



Result








Implementation

This post is licensed under CC BY 4.0 by the author.