I am analyzing a dataset on the quality of wines and want to focus on seperating the wine into two output nodes - one being a value <5 and one >5 in the output of the network code.
I was told I can do this with an ifelse but I am unsure of how the syntax works - ive tried to use the iris dataset as an example but im not sure that is entirely helpful.
nnet=neuralnet(quality~., input_train, hidden = 4, linear.output = FALSE)
plot(nnet)
# Predict the test data
ypred = neuralnet::compute(nnet, xtest)
SpecPred = ypred$net.result
print(SpecPred)
#Extract the class with the highest prediction
SpecPred=data.frame("Species"=ifelse(max.col(SpecPred[ ,1:3])==1, "5",
ifelse(max.col(SpecPred[ ,1:3])==2, "10")))
SpecPred
## Improving model performance ----
# a more complex neural network topology with 5 hidden neurons
set.seed(12345) # to guarantee repeatable results
input_model2 <- neuralnet(formula = quality ~ fixed.acidity + volatile.acidity + citric.acid + residual.sugar + chlorides + free.sulfur.dioxide + total.sulfur.dioxide + density + sulphates + alcohol + pH,
data = input_train, hidden=5)
model_results <- compute(input_model2, input_test[1:11])