Caret培训问题R

我最近开始使用caret套件,并且试图理解训练论点。 下面我使用了Sonar数据集并创建了三个输入和输出。

 library(caret)
 library(mlbench)
 data(Sonar)
 set.seed(107)
 SonarImput1<-Sonar[,1:60]
 SonarImput2<-Sonar[,1:2]
 SonarImput3<-Sonar[,1]
 SonarOutCome<-Sonar[,61]
 mlp <- caret::train(SonarImput1,SonarOutCome, method = "mlp", preProc = c("center", "scale"))
 mlp2 <- caret::train(SonarImput2,SonarOutCome, method = "mlp", preProc = c("center", "scale"))
 mlp3 <- caret::train(SonarImput3,SonarOutCome, method = "mlp", preProc = c("center", "scale"))

为什么mlp3会产生错误? 是否不可能只创建一个具有输出的预测器?

有什么不对; 所有精度度量值都丢失:在eval(expr,envir,enclos)中:Resample17的模型拟合失败:size = 3 x中的错误[modelIndex,,drop = FALSE]:不正确的维数


你需要为自变量(x)放置一个数据框而不是数字向量。 尝试这个

mlp3 <- caret::train(data.frame(x=SonarImput3),SonarOutCome, method = "mlp", preProc = c("center", "scale"))
链接地址: http://www.djcxy.com/p/38397.html

上一篇: Caret Training Issues in R

下一篇: How to reproduce $resample and $result of 'train' object in caret?