【问题标题】:Support Vector Machine classifier error [closed]支持向量机分类器错误
【发布时间】:2018-06-15 12:13:10
【问题描述】:

我不明白为什么当我运行 tune.svm 然后我运行摘要时,我只有这个结果:

使用 10 倍交叉验证对“svm”的误差估计:0.01385764,而我也期望最佳参数等。

我试过这个:

tuned <- tune.svm(y~.,
                  data = training,
                  gamma = 10^-2, cost = 10^2,
                  tunecontrol = tune.control(cross = 10))

summary(tuned)
#> Error estimation of ‘svm’ using 10-fold cross validation: 0.01385764

还有这个:

set.seed(222)
tunesvm <- tune(svm, y ~ ., data = training, kernel = "sigmoid",
                ranges = list(cost = 0.001)
plot(tunesvm)
summary(tunesvm)
#> Error estimation of ‘svm’ using 10-fold cross validation: 0.01788785

【问题讨论】:

  • 这决不能回答问题,但它是“支持向量机”而不是超级向量机。虽然我可能会用它作为歌曲名称:-)
  • 1. tune.svm 在什么包中?如果您在问题中包含 library 语句,将会有所帮助。 . 2.你试过str(tuned) 吗?
  • 图书馆(e1071)@G5W

标签: r machine-learning classification svm


【解决方案1】:

您遇到的问题是由于您已经为每个超参数指定了一个值。当每个参数都有一个可供选择时,您期望哪些最佳参数?

要获得最佳参数,您必须为超参数指定一系列值,CV 将通过网格搜索从中选择最佳组合。

这是一个完整的例子:

library(mlbench)
library(e1071)

data(Sonar)
set.seed(222)
tuned <- tune.svm(Class~.,
                  data = Sonar,
                  gamma = 10^(-1:-3), cost = 10^(1:3), ,
                  tunecontrol = tune.control(cross = 10))

summary(tuned)
#output:

Parameter tuning of ‘svm’:

- sampling method: 10-fold cross validation 

- best parameters:
 gamma cost
  0.01   10

- best performance: 0.1247619 

- Detailed performance results:
  gamma cost     error dispersion
1 0.100   10 0.2064286 0.08641724
2 0.010   10 0.1247619 0.07165924
3 0.001   10 0.2359524 0.08655125
4 0.100  100 0.2064286 0.08641724
5 0.010  100 0.1247619 0.07165924
6 0.001  100 0.2209524 0.09521693
7 0.100 1000 0.2064286 0.08641724
8 0.010 1000 0.1247619 0.07165924
9 0.001 1000 0.1823810 0.10762794

 plot(tuned)

【讨论】:

  • tnks,现在可以使用@missuse
猜你喜欢
  • 2011-07-01
  • 2013-08-31
  • 2017-08-18
  • 2015-02-16
  • 2018-10-12
  • 2019-01-26
  • 2011-10-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多