Support-Vector-Regression
Support-Vector-Regression
(SVM), primarily designed for regression tasks rather than classification. Instead
of categorizing data points into classes, SVR aims to predict a continuous
variable, like a price or temperature, while also maximizing generalization. SVR
is particularly effective for datasets with complex relationships due to its ability
to handle non-linear data with kernel functions.
Key Concepts in Support Vector Regression
1. Support Vectors: In SVR, support vectors are data points that lie closest to
the predicted hyperplane. These points influence the shape and position of
the regression hyperplane. The objective is to find the hyperplane that is at
most a certain margin away from these support vectors while minimizing
error.
2. Hyperplane: Just like in SVM, the SVR model seeks a hyperplane that
best fits the data points. In a two-dimensional space, this would be a line,
but in higher-dimensional spaces, it can be considered a flat, n-dimensional
plane.
3. Margin of Tolerance (Epsilon, £): The margin of tolerance is a critical
aspect of SVR. It represents the acceptable range within which predictions
can deviate from the actual values. The width of the epsilon margin (often
just called "epsilon") is specified as a parameter. Any point lying within
this epsilon-tube (margin) is not penalized, while points outside it incur a
penalty in the objective function.
4. Error Penalty (C): Another critical parameter is CCC, which defines the
trade-off between the model’s complexity (allowing more data points
outside the margin) and the prediction accuracy. A higher CCC value
allows more data points outside the margin, making the model more
sensitive to errors. A lower CCC value leads to a simpler, smoother model
but may result in underfitting.
Mathematical Formulation of SVR
Given data points yi), where X{ is the feature vector and yj is the target
predictions are as close as possible to the actual target values within the
margin e.
The objective of SVR is:
Minimize ^|M|2 +
C+ 4*)
t=l
subject to:
Vi - ( w ■ X i + b) <e+
4 (w ■ Xi + b) - yi <
e + 4*
4,4* >o
Where:
• ^i\xi_i^i and <^i*\xi_iA*^i* are slack variables for cases where points
fall outside the epsilon margin.
• CCC is the regularization parameter controlling the trade-off between
the flatness of the hyperplane and the amount of allowed deviation.
Kernel Functions in SVR
# Load dataset
dataset = pd.read csv(’Position Salaries.csv’)
X = dataset.iloc[:, 1:2].values y =
dataset.iloc[:, 2].values
# Feature Scaling
scX = StandardScaler()
scy = StandardScaler()
X = sc X.fit
transform(X)
y = sc y.fit
transform(y.reshape(-
1, 1)).flatten()
Applications of SVR
such as: