Caret Training Issues in R

I started playing with caret package recently and I'm trying to understand the training arguments. Below I used the Sonar dataset and created three imputs and the output.

 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"))

Why does mlp3 produces error? Is it not possible to create only one predictor with the outputs?

Something is wrong; all the Accuracy metric values are missing: In eval(expr, envir, enclos) : model fit failed for Resample17: size=3 Error in x[modelIndex, , drop = FALSE] : incorrect number of dimensions


you need to put a data frame instead of numeric vector for the independent variables (x). Try this

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

上一篇: 使用del df.column从pandas DataFrame中删除列

下一篇: Caret培训问题R