My dataset has 3 inputs and 3 outputs. I am trying to model a Neural network in R but getting some error while computing the testing output.
Here's what I've tried so far and in the next image I've attached the error that has been shown.
The dataset:
data <- structure(list(Vc = c(25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 45L, 45L, 45L,
45L, 45L, 45L, 45L, 45L, 45L), f = c(0.2, 0.15, 0.1, 0.15, 0.2,
0.1, 0.2, 0.15, 0.1, 0.2, 0.1, 0.15, 0.2, 0.1, 0.2, 0.15, 0.15,
0.1, 0.15, 0.1, 0.2, 0.1, 0.2, 0.2, 0.1, 0.15, 0.15), t = c(1,
1, 1, 1.25, 1.5, 1.25, 1.25, 1.5, 1.5, 1.5, 1, 1, 1.25, 1.25,
1, 1.5, 1.25, 1.5, 1, 1, 1.25, 1.25, 1, 1.5, 1.5, 1.5, 1.25),
Ra = c(0.6, 0.63, 0.32, 0.25, 0.606, 0.6363, 0.3232, 0.2525,
0.6, 0.63, 0.32, 0.25, 0.606, 0.6363, 0.3232, 0.2525, 0.57267,
0.29088, 0.22725, 0.54, 0.567, 0.288, 0.225, 0.5454, 0.57267,
0.29088, 0.22725), Fc = c(780, 562, 740, 630, 787.8, 567.62,
747.4, 636.3, 780, 562, 740, 630, 787.8, 567.62, 747.4, 636.3,
510.858, 672.66, 572.67, 702, 505.8, 666, 567, 709.02, 510.858,
672.66, 572.67), MRR = c(1090, 2250, 2305, 920, 1100.9, 2272.5,
2328.05, 929.2, 1090, 2250, 2305, 920, 1100.9, 2272.5, 2328.05,
929.2, 2045.25, 2095.245, 836.28, 981, 2025, 2074.5, 828,
990.81, 2045.25, 2095.245, 836.28)), class = "data.frame", row.names = c(NA,
-27L))
The code:
library(neuralnet)
library(NeuralNetTools)
datatrain = data[ 1:18, ]
datatest = data[ 19:27, ]
max = apply(data , 2 , max)
min = apply(data, 2 , min)
scaled = as.data.frame(scale(data, center = min, scale = max - min))
trainNN = scaled[1:18, ]
testNN= scaled[19:27,]
trainNN_m <- data.matrix(trainNN)
set.seed(2)
NN = neuralnet(as.formula(Ra+Fc+MRR ~ Vc + f + t), trainNN_m, hidden = c(3,5), linear.output = T)
plot(NN)
#Upto this point everything is okay, problem arising from here
testNN_m <- data.matrix(testNN)
predict_testNN = compute(NN, testNN_m[,c(1:3)])
The output I am getting:
I am really confused here. How to proceed?
Any help would mean a lot
question from:
https://stackoverflow.com/questions/65907603/error-in-computing-multiple-outputs-with-neuralnet-package