AIML Exp 9
AIML Exp 9
Import cereal dataset shared by Carnegie Mellon University (CMU). The details of the
dataset are on the following link: http://lib.stat.cmu.edu/DASL/Datafiles/Cereals.htm
The objective is to predict rating of the cereals variables such as calories, proteins, fat
etc. Test and Train using Neural Networks.
# install library
install.packages("neuralnet")
# load library
library(neuralnet)
plot(datatest$rating, predict_testNN, col='blue', pch=16, ylab = "predicted rating NN", xlab = "real rating")
abline(0,1)
# Load libraries
library(boot) library(plyr)
# Initialize variables
set.seed(50)
k = 100 RMSE.NN = NULL
List = list( )
6. Prepare boxplot
boxplot(Matrix.RMSE[,56], ylab = "RMSE", main = "RMSE BoxPlot (length of traning set = 65)")
7. Variation of median RMSE
install.packages("matrixStats")
library(matrixStats)
med = colMedians(Matrix.RMSE) X =
seq(10,65)
plot (med~X, type = "l", xlab = "length of training set", ylab = "median RMSE", main = "Variation of RMSE with
length of training set")
5. Observations/Discussions/ Complexity Analysis:
Neural network is inspired from biological nervous system. Similar to nervous system the
information is passed through layers of processors. The significance of variables is represented
by weights of each connection. The article provides basic understanding of back propagation
algorithm, which is used to assign these weights. In this article we also implement neural
network on R. We use a publically available dataset shared by CMU. The aim is to predict the
rating of cereals using information such as calories, fat, protein etc. After constructing the
neural network we evaluate the model for accuracy and robustness. We compute RMSE and
perform cross-validation analysis. In cross validation, we check the variation in model accuracy
as the length of training set is changed. We consider training sets with length 10 to 65. For each
length a 100 samples are random picked and median RMSE is calculated. We show that model
accuracy increases when training set is large. Before using the model for prediction, it is
important to check the robustness of performance through cross validation.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):