Support Vector Regression (SVR) based Prediction with R

Опубликовано: 15 Апрель 2026
на канале: Anindita Das Bhattacharjee
31,483
2.8k

In this video we will learn:-

Support Vector Regression (SVR).
Linear Regression v/s Support Vector Regression.
Kernel, Radial Basis Kernel, Polynomial Kernel, Linear Kernel, Cost Function in the context of Support Vector Regression.
Overfitting, Underfitting, Bias, Variance in the context of Support Vector Regression.
Support Vector, Epsilon Insensitive Tube, Slack Variable in the context of Support Vector Regression.
Support Vector Regression model Creation with R.
Outlier detection in the context of Support Vector Regression model.

Code for SVR -

Importing the dataset
dataset = read.csv('Position_Salaries.csv')
dataset = dataset[2:3]

#missing value checking
sum(is.na(dataset$Level))


Fitting SVR to the dataset
install.packages('e1071')
library(e1071)
regressor = svm(formula = Salary ~ .,
data = dataset,
type = 'eps-regression',
kernel = 'radial')

Predicting a new result
y_pred = predict(regressor, data.frame(Level = 6.5))

Visualising the SVR results
install.packages('ggplot2')
library(ggplot2)
ggplot() +
geom_point(aes(x = dataset$Level, y = dataset$Salary),
colour = 'red') +
geom_line(aes(x = dataset$Level, y = predict(regressor, newdata = dataset)),
colour = 'blue') +
ggtitle('Truth or Bluff (SVR)') +
xlab('Level') +
ylab('Salary')

Visualising the SVR results (for higher resolution and smoother curve)
install.packages('ggplot2')
library(ggplot2)
x_grid = seq(min(dataset$Level), max(dataset$Level), 0.1)
ggplot() +
geom_point(aes(x = dataset$Level, y = dataset$Salary),
colour = 'red') +
geom_line(aes(x = x_grid, y = predict(regressor, newdata = data.frame(Level = x_grid))),
colour = 'blue') +
ggtitle('Truth or Bluff (SVR)') +
xlab('Level') +
ylab('Salary')

Dataset (copy & save as Position_Salaries.csv)

Position Level Salary
Business Analyst 1 45000
Junior Consultant 2 50000
Senior Consultant 3 60000
Manager 4 80000
Country Manager 5 110000
Region Manager 6 150000
Partner 7 200000
Senior Partner 8 300000
C-level 9 500000
CEO 10 1000000