在不调整 R 的情况下在 Caret 中训练模型

Nit*_*tro 4 r data-mining r-caret

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

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

出了问题;所有 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    
Run Code Online (Sandbox Code Playgroud)

train.default(x,y,weights = w,...)中的错误:停止另外:警告消息:在nominalTrainWorkflow(x = x,y = y,wts =weights,info = trainInfo,:存在缺失值在重新抽样的绩效指标中。

Nit*_*tro 6

我想到了一种方法,有点晦涩难懂。您必须创建一个传递给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
Run Code Online (Sandbox Code Playgroud)