r - 在不调整 R 的情况下使用 Caret 训练模型

标签 r data-mining r-caret

<分区>

似乎在 caret 中训练模型时,您几乎被迫进行参数调整。我知道这通常是个好主意,但如果我想在训练时明确说明模型参数怎么办?

svm.nf <- train(y ~ .,
                data = nf,
                method = "svmRadial",
                C = 4, sigma = 0.25, tuneLength = 0)

出了点问题;缺少所有 RMSE 指标值:

    RMSE        Rsquared  
 Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA  
 NA's   :2     NA's   :2    

Error in train.default(x, y, weights = w, ...) : Stopping In addition: Warning message: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, : There were missing values in resampled performance measures.

最佳答案

我想出了一个办法,有点晦涩难懂。您必须创建一个传递给 tuneGrid 的调优参数数据框,但每个参数只列出 1 个值。

params <- data.frame(C = 4,sigma=.25)

> params
  C sigma
1 4  0.25

svm.nf <- train(Point_diff ~ .,
              data = nf,
              method = "svmRadial",
              tuneGrid=params)
> svm.nf
Support Vector Machines with Radial Basis Function Kernel 

1248 samples
14 predictor

No pre-processing
Resampling: Bootstrapped (25 reps) 
Summary of sample sizes: 1248, 1248, 1248, 1248, 1248, 1248, ... 
Resampling results:

  RMSE      Rsquared 
  15.53451  0.0550965

Tuning parameter 'sigma' was held constant at a value of 0.25
Tuning parameter 'C'was held constant at a value of 4

关于r - 在不调整 R 的情况下使用 Caret 训练模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39665818/

相关文章:

r - 在 R 中,我可以停止 print(cat ("")) 返回 NULL 吗?为什么 cat ("foo") 返回 foo>

r - 将 ipython 笔记本中 ggplot 的输出保存到文件

r - 创建 ggplot2 函数并根据 ggplot2 标准功能将参数指定为数据中的变量

r - 在 R 中将字符串转换为日期会返回 NA

python - 求多元正态分布中的概率

machine-learning - 计算电信CDR数据中用户的影响力

R 插入符 : What causes error "undefined columns selected" using sbf and method "ranger"?

data-mining - 从开发人员的角度来看,什么是数据挖掘?

r - 使用配方和插入符的 preProcess 进行预处理的差异

r - 是否有任何变通方法可以从 Rstudio 中获取插入符包工作的 train() 函数?