【问题标题】:Caret - Scaling SVM tuning parametert (Sigma) when using plot.trainCaret - 使用 plot.train 时缩放 SVM 调整参数 (Sigma)
【发布时间】:2015-11-22 11:54:19
【问题描述】:

我正在使用 Caret 包来调整 SVM 模型。

在绘制结果时,有没有办法缩放Sigma 值类似于Cost 值(如附图所示)。

这是我的调整值:

svmGrid <- expand.grid(sigma= 2^c(-25, -20, -15,-10, -5, 0), C= 2^c(0:5))

生成情节的代码:

pdf("./Figures/svm/svmFit_all.pdf", width=7, height = 5)
trellis.par.set(caretTheme())
plot(svmFit.all, scales = list(x = list(log = 2)))
dev.off()

谢谢

【问题讨论】:

    标签: r svm r-caret


    【解决方案1】:

    你必须通过 lattice 自己做:

    library(caret)
    
    set.seed(1345)
    dat <- twoClassSim(2000)
    
    svmGrid <- expand.grid(sigma= 2^c(-25, -20, -15,-10, -5, 0), C= 2^c(0:5))
    
    set.seed(45)
    mod <- train(Class ~ ., data = dat, 
                 method = "svmRadial",
                 preProc = c("center", "scale"),
                 tuneGrid = svmGrid,
                 metric = "ROC",
                 trControl = trainControl(method = "cv", 
                                          classProbs = TRUE, 
                                          summaryFunction = twoClassSummary))
    
    tmp <- mod$results
    tmp$sigma2 <- paste0("2^", format(log2(tmp$sigma)))
    
    xyplot(ROC ~ C, data = tmp, 
           groups = sigma2,
           type = c("p", "l"),
           auto.key = list(columns = 4, lines = TRUE),
           scales = list(x = list(log = 2)),
           xlab = "Cost", 
           ylab = "ROC (Cross-Validation)")
    

    最大

    【讨论】:

    • 感谢 Max 的快速回复和解决方案。高度赞赏。再次祝贺 Ziegel 奖。
    猜你喜欢
    • 2016-11-20
    • 2021-10-12
    • 1970-01-01
    • 2013-01-12
    • 1970-01-01
    • 2018-07-05
    • 2018-03-29
    • 2018-06-10
    • 1970-01-01
    相关资源
    最近更新 更多