I've gotten an error message when attempting to plot a neural network. I was able to run the code fine at first then it stopped. I do not get an error message when the neuralnet() function is run. Any help would be appreciated. I predicting the loan default.
library(neuralnet)
library(plyr)
CreditCardnn <- read.csv("https://raw.githubusercontent.com/621-Group2/Final-Project/master/UCI_Credit_Card.csv")
#Normalize dataset
maxValue <- apply(CreditCardnn, 2, max)
minValue <- apply(CreditCardnn, 2, min)
CreditCardnn <- as.data.frame(scale(CreditCardnn, center = minValue, scale = maxValue - minValue))
#Rename to target variable
colnames(CreditCardnn)[25] <- "target"
smp <- floor(0.70 * nrow(CreditCardnn))
set.seed(4784)
CreditCardnn$ID <- NULL
train_index <- sample(seq_len(nrow(CreditCardnn)), size = smp, replace = FALSE)
train_nn <- CreditCardnn[train_index, ]
test_nn <- CreditCardnn[-train_index, ]
allVars <- colnames(CreditCardnn)
predictorVars <- allVars[!allVars%in%'target']
predictorVars <- paste(predictorVars, collapse = "+")
f <- as.formula(paste("target~", predictorVars, collapse = "+"))
nueralModel <- neuralnet(formula = f, hidden = c(4,2), linear.output = T, data = train_nn)
plot(nueralModel)
Which gives the following error:
Error in plot.nn(nueralModel) : weights were not calculated