machine learning – R neuralNet: non-conformable arguments
machine learning – R neuralNet: non-conformable arguments
It looks like you need to remove the predictor variable. Try this:
nn_pred<-compute(nn,test[,3:11])
I tried this with the neuralnet package as well. I think if you instead of
net.results <- compute(
net, matrix.train2
do
net.result <- compute(
net, matrix.train2[,c(pclass,
sexmale, age, sibsp, parch,
fare,embarkedC,embarkedQ,embaredS)])
it should work. The names of the variables needs to be in the exact order of the model.list$variables
, so you can also type
net.result <- compute(
net, matrix.train2[, net.result$model.list$variables])
I hope this helps. The reason is – I think – that neuralnet has a problem finding out which variables are in your net and which in the matrix… so you match them explicitly instead.
machine learning – R neuralNet: non-conformable arguments
I havent used the neuralnet ackage, but unless its doing something weird you shouldnt be calling model.matrix
like that. neuralnet
has a formula interface, so it will call model.matrix
for you. You just have to give it the training data frame train1
.
This also applies for predicting on test data. Dont create a model matrix; just pass it the data frame train2
.