predicting class for new data using neuralnet

前端 未结 3 1590
無奈伤痛
無奈伤痛 2021-02-14 07:31

I\'m trying to predict the class (0 or 1) for a test dataset using a neural network trained using the neuralnet package in R.

The data I have looks as follows:

相关标签:
3条回答
  • Hard to say in the absence of a good description of the 'test'-object, but can you see if this gives better results:

    compute(nn, test[, 1:4])
    
    0 讨论(0)
  • 2021-02-14 08:12

    I know this is an old post, but I came across a unique piece that may help someone in the future. Thought this post was most applicable as it throws the same error.

    Scaling of a dataset must be converted back into a data.frame for use in compute

    #scaled data
    scaledData=scale(data)
    nn=neuralnet(y~x,data=scaledData[train,])
    
    #this repeatedly failed for me
    compute(nn,scaledData[test,])
    
    #this worked 
    compute(nn,as.data.frame(scaledData)[test,])
    
    0 讨论(0)
  • 2021-02-14 08:18

    I had the same problem. I put debugonce(neuralnet) and I discovered neuralnet was multiplying matrix from different sizes.

    I solved the problem removing the y column from test with this function

    columns <- c("x1","x2","x3","x4")
    covariate <- subset(test, select = columns)
    
    0 讨论(0)
提交回复
热议问题