Caret包自己的示例在R上不起作用

我安装了插入记号,以尝试估算CV为10倍的OLS模型。

x <- rnorm(100)
epsion <- rnorm(100)
y <- x+x^2+x^3+x^4+epsilon

df <- data.frame(y=y,x=x,x2=x^2,x3=x^3,x4=x^4)

model <- train(
  y~x2+x3,df,method = "glm",tuneLength = 10,trControl = trainControl(method="cv"))

我收到以下错误消息:

Something is wrong; all the RMSE metric values are missing:
      RMSE        Rsquared        MAE     
 Min.   : NA   Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA   Max.   : NA  
 NA's   :1     NA's   :1     NA's   :1    
Error: Stopping
In addition: There were 11 warnings (use warnings() to see them)

警告是:

1: predictions failed for Fold1: parameter=none Error in terms.formula(object,data = data) : 
  argument is not a valid model

对于Fold1到Fold10重复10次,并出现第11条错误消息:

11: In nominalTrainWorkflow(x = x,y = y,wts = weights,info = trainInfo,... :
  There were missing values in resampled performance measures.

即使我只是复制并粘贴插入符号自己的代码示例

data(iris)
TrainData <- iris[,1:4]
TrainClasses <- iris[,5]
knnFit1 <- train(TrainData,TrainClasses,method = "knn",preProcess = c("center","scale"),trControl = trainControl(method = "cv"))

出现50条警告消息,它们都很像

50: predictions failed for Fold05: k=23 Error in terms.formula(object,data = data) : 
  argument is not a valid model

倍数和k不同。

我的R是否有问题?

redrex5 回答:Caret包自己的示例在R上不起作用

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3113529.html

大家都在问