I have a training kit that looks like
Name Day Area XY Month Night ATTACK Monday LA -122.41 37.78 8 0 VEHICLE Saturday CHICAGO -1.67 3.15 2 0 MOUSE Monday TAIPEI -12.5 3.1 9 1
Name is the variable result / depend. I converted Name , Area and Day to factors, but I was not sure if I should be for Month and Night , which only accept integer values 1-12 and 0-1, respectively.
I then convert the data to a matrix
ynn <- model.matrix(~Name , data = trainDF) mnn <- model.matrix(~ Day+Area +X + Y + Month + Night, data = trainDF)
Then I adjust the settings
nnTrControl=trainControl(method = "repeatedcv",number = 3,repeats=5,verboseIter = TRUE, returnData = FALSE, returnResamp = "all", classProbs = TRUE, summaryFunction = multiClassSummary,allowParallel = TRUE) nnGrid = expand.grid(.size=c(1,4,7),.decay=c(0,0.001,0.1)) model <- train(y=ynn, x=mnn, method='nnet',linout=TRUE, trace = FALSE, trControl = nnTrControl,metric="logLoss", tuneGrid=nnGrid)
However, I get the error Error: nrow(x) == n is not TRUE for model<-train
I also get a similar error if I use xgboost instead of nnet
Does anyone know what causes this?
r dataframe neural-network r-caret
user5739619
source share