0% found this document useful (0 votes)
73 views6 pages

Worksheet No. 9: 1. Aim/Overview of The Practical

The document is a student worksheet for an AI/ML lab practical. The objective was to import and analyze a cereal dataset to predict ratings. The student: 1) Imported and viewed the cereal dataset. 2) Created a neural network model and plotted it to predict median home value (medv) based on other variables. 3) Calculated the model results, accuracy, and compared actual vs predicted values, finding an accuracy of [ACCURACY VALUE].

Uploaded by

BLACKER EMPIRE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views6 pages

Worksheet No. 9: 1. Aim/Overview of The Practical

The document is a student worksheet for an AI/ML lab practical. The objective was to import and analyze a cereal dataset to predict ratings. The student: 1) Imported and viewed the cereal dataset. 2) Created a neural network model and plotted it to predict median home value (medv) based on other variables. 3) Calculated the model results, accuracy, and compared actual vs predicted values, finding an accuracy of [ACCURACY VALUE].

Uploaded by

BLACKER EMPIRE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Worksheet No.

Student Name: Arshpreet Singh UID: 18BCS6570


Branch: BE-CSE Section/Group: 18_K2_G2
Semester: 5 Date of Performance: 12/5/20
Subject Name: AI/ML Lab Subject Code: CSP-303

1. Aim/Overview of the practical:


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.html​. The objective is
to predict the rating of the cereals variables such as calories, proteins, fat etc. Test and Train
using Neural Networks.

CODE (1) : Viewing the Dataset


install.packages("MASS")
library("MASS")
dataset=Boston;dataset
View(dataset)
max = apply(dataset, 2 , max)
min = apply(dataset, 2 , min)
scaled_dataset = as.data.frame(scale(dataset, center = min, scale =
max - min))
scaled_dataset
Output:

CODE (2) : Plotting the Neural Network


install.packages("caTools")
library(caTools)
set.seed(123)
sample = sample.split(scaled_dataset$medv, SplitRatio = 0.6)
training_set = subset(scaled_dataset, sample==TRUE)
test_set = subset(scaled_dataset, sample==FALSE)

install.packages("neuralnet")
library(neuralnet)
set.seed(2)
allvars=colnames(dataset);allvars
predictorvars=allvars[!allvars%in%"medv"];predictorvars
predictorvars=paste(predictorvars,collapse="+");predictorvars
form=as.formula(paste("medv~",predictorvars,collapse="+"))
form

nn=neuralnet(formula =form,data =training_set,hidden


=c(4,2),threshold=0.01)
plot(nn)

Neural Net Plot :


CODE (3) : Calculating the result & accuracy
nn.results=compute(nn,test_set[,1:13])
results<- data.frame(actual = test_set$medv, prediction =
nn.results$net.result);results
predicted=(results$prediction * (max(dataset$medv) -
min(dataset$medv))) + min(dataset$medv)
actual=(results$actual * (max(dataset$medv) - min(dataset$medv))) +
min(dataset$medv)
comparison=data.frame(predicted,actual)
deviation=((actual-predicted)/actual);deviation
comparison=data.frame(predicted,actual,deviation)
accuracy=1-abs(mean(deviation))
accuracy
Accuracy Output:
Learning outcomes (What I have learnt):

1. Got to know about Neural Networks.

2. Learned to use library files used to create Neural Networks in R.

3. Learned about calculating the Accuracy for a Neural Network.

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1.
2.
3.

You might also like