R - avNNet - Predict function returns less number of rows than in test function

1.4k views Asked by At

I am trying avNNet for one of the projects of classification with 1's and 0's.

In my test dataset I have 116293. But output of predict function returns only 106388 records.

And shocker is all are 0's!!! I might be doing some mistake. Please some one guide me to use avNNet.

The code looks as follows:

nnet_train = avNNet(WnvPresent~. ,data = xtrain, size=10)
str(xtest) #116293 obs. of  16 variables
PredTest = predict(nnet_train, newdata = xtest)
str(PredTest) #Named num [1:106388] 
summary(PredTest) 
1

There are 1 answers

0
Abhimanu Kumar On

This happens when you have columns with NAs in your data (xtest here). predict() will skip rows that have NA in any of its columns.

I know its late, but I hope it is helpful to the posterity.