Error: nrow(x) == n is not TRUE when using Train in Caret

落爺英雄遲暮 提交于 2019-12-01 16:25:07

y should be a numeric or factor vector containing the outcome for each sample, not a matrix. Using

train(y = make.names(trainDF$Name), ...)

helps, where make.names modifies values so that they could be valid variable names.

Even though in the help file of train said either maxtrix or data frame would be expected, but you can try to convert the matrix to a data frame:

model <- train(y=ynn, x=as.data.frame(mnn), method='nnet',linout=TRUE, trace = FALSE, trControl = nnTrControl,metric="logLoss", tuneGrid=nnGrid)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!