目前我自己对SVR的理解就是在一定范围内提高模型精度
在SVR模式下用数据喂养模型
# Fitting SVR to the dataset
install.packages('e1071')
library(e1071)
regressor = svm(formula = Salary ~ .,
data = dataset,
type = 'eps-regression',
kernel = 'radial')
再预测下 6.5Level 的薪资
再将数据可视化下
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')
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 (SVR1)') +
xlab('Level') +
ylab('Salary')