Alex Rivera | Logout

how to predict new cases using the neuralnet package

Asked 2011-02-03T21:23:30.547
12

Using RGUI. I have a dataset called Data. The response variable that I'm interested in is contained in the first column of Data.

I have training sets of Data called DataTrain and DataTest.

With DataTrain I trained a neural network model (called DataNN) using the package and function neuralnet.

> DataNN = neuralnet(DataTrain[,1] ~ DataTrain[,2] + DataTrain[,3], hidden = 1,
    data = DataTrain) 

Does anyone know how to create a prediction on this model using the test set (DataTest)?

Normally (for other models) I would use predict() for this. E.g.

> DataPred = predict(DataNN, DataTest)

But when doing this for neuralnet I get:

> DataPred = predict(DataNN, DataTest)

Error in UseMethod("predict") : 
no applicable method for 'predict' applied to an object of class "nn"  

Obviously I can't run predict() on this model. Does anyone know of any alternatives?

I've checked the help for neuralnet and I found a method called prediction in the page 12 of the documentation. I don't think it's what I want at all though, or at least I don't know how to apply it to my Data.

Any help would be appreciated (if there is any solution to this at all).

Edit
Report

1 Answer

2

The function for prediction is prediction, not predict.

So try DataPred = prediction(DataNN, DataTest) instead of DataPred = predict(DataNN, DataTest).

answered 2012-10-05T04:43:35.050

Your Answer