gpt4 book ai didi

r - 支持向量机分类器错误

转载 作者:行者123 更新时间:2023-11-30 09:49:06 26 4
gpt4 key购买 nike

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

Error estimation of ‘svm’ using 10-fold cross-validation: 0.01385764, whereas I expect also best parameters etc..

我尝试过这个:

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

最佳答案

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

要获得最佳参数,您必须为超参数指定一系列值,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)

enter image description here

关于r - 支持向量机分类器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48117722/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com