Neural Network Prediction Modeling for Predicting Graduate Admissions And Using Confusion Matrix to Check Its Validity in R

The program code is used for predicting Graduate Admissions which uses the Neural Network Prediction Model and Cross-validation to split the dataset into training and testing data and the Confusion Matrix to check its validity. The dataset was downloaded from www.kaggle.com, below is the dataset download link; https://www.kaggle.com/mohansacharya/graduate-admissions


library(neuralnet)
setwd("C:\\Users\\LENOVO\\Desktop\\Neural")
admission <- read.csv("admission.csv", header = TRUE)
admission
str(admission)

normalize <- function(x) {
  return((x - min(x)) / (max(x) - min(x)))
}
maxin <- as.data.frame(lapply(admission, normalize))
maxin


trainset <- maxin[1:400,]
#trainset
testset <- maxin[401:500,]

nn <- neuralnet(Chance ~ GRE + TOEFL + SOP + LOR + CGPA + Research, data=trainset,
                hidden =c(4,2), linear.output = FALSE)
nn$result.matrix
plot(nn)

temp_test <- subset(testset, select = c("GRE","TOEFL","SOP","LOR","CGPA","Research","Chance"))
head(temp_test)
nn.results <- compute(nn, testset)

##Prediction
results <- data.frame(actual = testset$Chance, prediction= nn.results$net.result)
results

###Confusion matrix
roundedresults <- sapply(results, round, digits=0)
roundedresultsdf <- data.frame(roundedresults)
attach(roundedresultsdf)
table(actual, prediction)

Comments

Popular posts from this blog

Linear Regression Prediction Model for predicting Graduate Admissions in Python with Scikit-Learn