SlideShare a Scribd company logo
Neural Network in R
Introduction
 Neural network is an information-processing machine and can be viewed
as analogous to human nervous system.
 Just like human nervous system, which is made up of interconnected
neurons, a neural network is made up of interconnected information
processing units.
 The information processing units do not work in a linear manner.
 In fact, neural network draws its strength from parallel processing of
information, which allows it to deal with non-linearity.
Basics
 A neural network is a model characterized by an activation function, which
is used by interconnected information processing units to transform input
into output.
 The first layer of the neural network receives the raw input, processes it
and passes the processed information to the hidden layers. The hidden
layer passes the information to the last layer, which produces the output.
 NN learns from the information provided, i.e. trains itself from the data,
which has a known outcome and optimizes its weights for a better
prediction in situations with unknown outcome.
Continue…
 A perceptron, viz. single layer neural network, is the most basic form of a
neural network.
 A perceptron receives multidimensional input and processes it using a
weighted summation and an activation function.
 It is trained using a labeled data and learning algorithm that optimize the
weights in the summation processor.
 A major limitation of perceptron model is its inability to deal with non-
linearity.
 A multilayered neural network overcomes this limitation and helps solve
non-linear problems.(Input layer, Hidden layer, Output layer)
Rules in Neural Networks
 There are many learning rules that are used with neural network:
 a) least mean square;
b) gradient descent;
c) newton’s rule;
d) conjugate gradient etc.
 The learning rules can be used in conjunction with back-propgation error method. The
learning rule is used to calculate the error at the output unit.
 This error is back-propagated to all the units such that the error at each unit is
proportional to the contribution of that unit towards total error at the output unit. The
errors at each unit are then used to optimize the weight at each connection.
Structure of Simple Neural Network
Lets try an example in R
 The objective is to predict rating of the cereals variables such as calories,
proteins, fat etc.
 Data is provided with name cereals.csv ,we use a subset of cereal dataset
shared by Carnegie Mellon University (CMU)
 Please set working directory in R using setwd( ) function, and keep
cereal.csv in the working directory.
 We use rating as the dependent variable and calories, proteins, fat, sodium
and fiber as the independent variables.
Process
 We divide the data into training and test set.
 Training set is used to find the relationship between dependent and
independent variables while the test set assesses the performance of the
model.
 We use 60% of the dataset as training set. The assignment of the data to
training and test set is done using random sampling.
R script
 # Read the Data
 Data <- read.csv("cereals.csv", header=T)
 # Random sampling
 samplesize <- 0.60 * nrow(data)
 set.seed(80)
 index <- sample( seq_len ( nrow ( data ) ), size = samplesize )
 # Create training and test set
 datatrain <- data[ index, ]
 datatest <- data[ -index, ]
Fitting Neural Network
 We fit a neural network on our data. We use ”neuralnet” library for the
analysis.
 The common techniques to scale data are: min-max normalization, Z-
score normalization, median and MAD, and tan-h estimators. The min-max
normalization transforms the data into a common range, thus removing
the scaling effect from all the variables.
 We use min-max normalization to scale the data.
R Script
 ## Scale data for neural network
 max = apply(data , 2 , max) min = apply(data, 2 , min)
 scaled = as.data.frame(scale(data, center = min, scale = max - min))
# install library
install.packages("neuralnet ")
# load library
library(neuralnet)
# creating training and test set
trainNN = scaled[index , ]
testNN = scaled[-index , ]
 # fit neural network
 set.seed(2)
 NN = neuralnet(rating ~ calories + protein + fat + sodium + fiber, trainNN,
hidden = 3 , linear.output = T )
 # plot neural network
 plot(NN)
Output Plot

More Related Content

What's hot

Learning Methods in a Neural Network
Learning Methods in a Neural NetworkLearning Methods in a Neural Network
Learning Methods in a Neural Network
Saransh Choudhary
 
Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.
Mohd Faiz
 
Introduction to Neural networks (under graduate course) Lecture 1 of 9
Introduction to Neural networks (under graduate course) Lecture 1 of 9Introduction to Neural networks (under graduate course) Lecture 1 of 9
Introduction to Neural networks (under graduate course) Lecture 1 of 9
Randa Elanwar
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
Prakash K
 
Perceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsPerceptron and Sigmoid Neurons
Perceptron and Sigmoid Neurons
Shajun Nisha
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
sweetysweety8
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
Mohd Arafat Shaikh
 
06 neurolab python
06 neurolab python06 neurolab python
06 neurolab python
Tamer Ahmed Farrag, PhD
 
Data Science - Part VIII - Artifical Neural Network
Data Science - Part VIII -  Artifical Neural NetworkData Science - Part VIII -  Artifical Neural Network
Data Science - Part VIII - Artifical Neural Network
Derek Kane
 
Kcc201728apr2017 170828235330
Kcc201728apr2017 170828235330Kcc201728apr2017 170828235330
Kcc201728apr2017 170828235330
JEE HYUN PARK
 
Artificial Intelligence- Neural Networks
Artificial Intelligence- Neural NetworksArtificial Intelligence- Neural Networks
Artificial Intelligence- Neural Networks
Learnbay Datascience
 
Neural Computing
Neural ComputingNeural Computing
Neural Computing
Jehoshaphat Abu
 
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Randa Elanwar
 
Neural networks
Neural networksNeural networks
Soft computing
Soft computingSoft computing
Soft computing
SangeethaSasi1
 
02 Fundamental Concepts of ANN
02 Fundamental Concepts of ANN02 Fundamental Concepts of ANN
02 Fundamental Concepts of ANN
Tamer Ahmed Farrag, PhD
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networks
jabedskakib
 
Neuralnetwork 101222074552-phpapp02
Neuralnetwork 101222074552-phpapp02Neuralnetwork 101222074552-phpapp02
Neuralnetwork 101222074552-phpapp02Deepu Gupta
 

What's hot (20)

Learning Methods in a Neural Network
Learning Methods in a Neural NetworkLearning Methods in a Neural Network
Learning Methods in a Neural Network
 
Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.
 
Introduction to Neural networks (under graduate course) Lecture 1 of 9
Introduction to Neural networks (under graduate course) Lecture 1 of 9Introduction to Neural networks (under graduate course) Lecture 1 of 9
Introduction to Neural networks (under graduate course) Lecture 1 of 9
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
 
Perceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsPerceptron and Sigmoid Neurons
Perceptron and Sigmoid Neurons
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
AI IEEE
AI IEEEAI IEEE
AI IEEE
 
06 neurolab python
06 neurolab python06 neurolab python
06 neurolab python
 
Data Science - Part VIII - Artifical Neural Network
Data Science - Part VIII -  Artifical Neural NetworkData Science - Part VIII -  Artifical Neural Network
Data Science - Part VIII - Artifical Neural Network
 
Kcc201728apr2017 170828235330
Kcc201728apr2017 170828235330Kcc201728apr2017 170828235330
Kcc201728apr2017 170828235330
 
Artificial Intelligence- Neural Networks
Artificial Intelligence- Neural NetworksArtificial Intelligence- Neural Networks
Artificial Intelligence- Neural Networks
 
Neural Computing
Neural ComputingNeural Computing
Neural Computing
 
Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9Introduction to Neural networks (under graduate course) Lecture 9 of 9
Introduction to Neural networks (under graduate course) Lecture 9 of 9
 
Neural networks
Neural networksNeural networks
Neural networks
 
Soft computing
Soft computingSoft computing
Soft computing
 
02 Fundamental Concepts of ANN
02 Fundamental Concepts of ANN02 Fundamental Concepts of ANN
02 Fundamental Concepts of ANN
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networks
 
Ann
Ann Ann
Ann
 
Neuralnetwork 101222074552-phpapp02
Neuralnetwork 101222074552-phpapp02Neuralnetwork 101222074552-phpapp02
Neuralnetwork 101222074552-phpapp02
 

Similar to Neural network in R by Aman Chauhan

Neural network
Neural networkNeural network
Neural network
Saddam Hussain
 
Neural Networks in Data Mining - “An Overview”
Neural Networks  in Data Mining -   “An Overview”Neural Networks  in Data Mining -   “An Overview”
Neural Networks in Data Mining - “An Overview”
Dr.(Mrs).Gethsiyal Augasta
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
Ismail El Gayar
 
AI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
AI Class Topic 6: Easy Way to Learn Deep Learning AI TechnologiesAI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
AI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
Value Amplify Consulting
 
Neural Networks AI presentation.pdf
Neural Networks AI presentation.pdfNeural Networks AI presentation.pdf
Neural Networks AI presentation.pdf
ahti04960
 
Deep Learning With Neural Networks
Deep Learning With Neural NetworksDeep Learning With Neural Networks
Deep Learning With Neural Networks
Aniket Maurya
 
Electricity Demand Forecasting Using ANN
Electricity Demand Forecasting Using ANNElectricity Demand Forecasting Using ANN
Electricity Demand Forecasting Using ANNNaren Chandra Kattla
 
Feed forward neural network for sine
Feed forward neural network for sineFeed forward neural network for sine
Feed forward neural network for sine
ijcsa
 
Neural-Networks.ppt
Neural-Networks.pptNeural-Networks.ppt
Neural-Networks.ppt
RINUSATHYAN
 
neuralnetwork.pptx
neuralnetwork.pptxneuralnetwork.pptx
neuralnetwork.pptx
Karthik Rohan
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
NikitaRuhela
 
Neural networks
Neural networksNeural networks
Neural networks
Rizwan Rizzu
 
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptxminimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
ElizanderGalasi1
 
Neural network based numerical digits recognization using nnt in matlab
Neural network based numerical digits recognization using nnt in matlabNeural network based numerical digits recognization using nnt in matlab
Neural network based numerical digits recognization using nnt in matlab
ijcses
 
Neural network
Neural network Neural network
Neural network
Faireen
 
Artificial Neural Network for machine learning
Artificial Neural Network for machine learningArtificial Neural Network for machine learning
Artificial Neural Network for machine learning
2303oyxxxjdeepak
 
Artificial Neural Network ANN
Artificial Neural Network ANNArtificial Neural Network ANN
Artificial Neural Network ANN
Abdullah al Mamun
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
mustafa aadel
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
GauravPandey319
 
Artificial neural networks
Artificial neural networks Artificial neural networks
Artificial neural networks
ShwethaShreeS
 

Similar to Neural network in R by Aman Chauhan (20)

Neural network
Neural networkNeural network
Neural network
 
Neural Networks in Data Mining - “An Overview”
Neural Networks  in Data Mining -   “An Overview”Neural Networks  in Data Mining -   “An Overview”
Neural Networks in Data Mining - “An Overview”
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
AI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
AI Class Topic 6: Easy Way to Learn Deep Learning AI TechnologiesAI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
AI Class Topic 6: Easy Way to Learn Deep Learning AI Technologies
 
Neural Networks AI presentation.pdf
Neural Networks AI presentation.pdfNeural Networks AI presentation.pdf
Neural Networks AI presentation.pdf
 
Deep Learning With Neural Networks
Deep Learning With Neural NetworksDeep Learning With Neural Networks
Deep Learning With Neural Networks
 
Electricity Demand Forecasting Using ANN
Electricity Demand Forecasting Using ANNElectricity Demand Forecasting Using ANN
Electricity Demand Forecasting Using ANN
 
Feed forward neural network for sine
Feed forward neural network for sineFeed forward neural network for sine
Feed forward neural network for sine
 
Neural-Networks.ppt
Neural-Networks.pptNeural-Networks.ppt
Neural-Networks.ppt
 
neuralnetwork.pptx
neuralnetwork.pptxneuralnetwork.pptx
neuralnetwork.pptx
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Neural networks
Neural networksNeural networks
Neural networks
 
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptxminimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
minimalist-business-slides.v dsgjnejgndjgnejgnjgnrjhgdjgngdngtpptx
 
Neural network based numerical digits recognization using nnt in matlab
Neural network based numerical digits recognization using nnt in matlabNeural network based numerical digits recognization using nnt in matlab
Neural network based numerical digits recognization using nnt in matlab
 
Neural network
Neural network Neural network
Neural network
 
Artificial Neural Network for machine learning
Artificial Neural Network for machine learningArtificial Neural Network for machine learning
Artificial Neural Network for machine learning
 
Artificial Neural Network ANN
Artificial Neural Network ANNArtificial Neural Network ANN
Artificial Neural Network ANN
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial neural networks
Artificial neural networks Artificial neural networks
Artificial neural networks
 

Recently uploaded

一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
aozcue
 
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
arcosarturo900
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
lorraineandreiamcidl
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
aozcue
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
peuce
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Peter Gallagher
 
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
andreassenrolf537
 
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdfSchematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
nikoloco007
 

Recently uploaded (8)

一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
 
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
天博体育下载-可靠的网络天博体育下载-网络天博体育下载|【​网址​🎉ac123.net🎉​】
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
 
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
 
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdfSchematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
Schematic Diagram MSI MS-7309 - REV 1.0 PDF .pdf
 

Neural network in R by Aman Chauhan

  • 2. Introduction  Neural network is an information-processing machine and can be viewed as analogous to human nervous system.  Just like human nervous system, which is made up of interconnected neurons, a neural network is made up of interconnected information processing units.  The information processing units do not work in a linear manner.  In fact, neural network draws its strength from parallel processing of information, which allows it to deal with non-linearity.
  • 3. Basics  A neural network is a model characterized by an activation function, which is used by interconnected information processing units to transform input into output.  The first layer of the neural network receives the raw input, processes it and passes the processed information to the hidden layers. The hidden layer passes the information to the last layer, which produces the output.  NN learns from the information provided, i.e. trains itself from the data, which has a known outcome and optimizes its weights for a better prediction in situations with unknown outcome.
  • 4. Continue…  A perceptron, viz. single layer neural network, is the most basic form of a neural network.  A perceptron receives multidimensional input and processes it using a weighted summation and an activation function.  It is trained using a labeled data and learning algorithm that optimize the weights in the summation processor.  A major limitation of perceptron model is its inability to deal with non- linearity.  A multilayered neural network overcomes this limitation and helps solve non-linear problems.(Input layer, Hidden layer, Output layer)
  • 5. Rules in Neural Networks  There are many learning rules that are used with neural network:  a) least mean square; b) gradient descent; c) newton’s rule; d) conjugate gradient etc.  The learning rules can be used in conjunction with back-propgation error method. The learning rule is used to calculate the error at the output unit.  This error is back-propagated to all the units such that the error at each unit is proportional to the contribution of that unit towards total error at the output unit. The errors at each unit are then used to optimize the weight at each connection.
  • 6. Structure of Simple Neural Network
  • 7. Lets try an example in R  The objective is to predict rating of the cereals variables such as calories, proteins, fat etc.  Data is provided with name cereals.csv ,we use a subset of cereal dataset shared by Carnegie Mellon University (CMU)  Please set working directory in R using setwd( ) function, and keep cereal.csv in the working directory.  We use rating as the dependent variable and calories, proteins, fat, sodium and fiber as the independent variables.
  • 8. Process  We divide the data into training and test set.  Training set is used to find the relationship between dependent and independent variables while the test set assesses the performance of the model.  We use 60% of the dataset as training set. The assignment of the data to training and test set is done using random sampling.
  • 9. R script  # Read the Data  Data <- read.csv("cereals.csv", header=T)  # Random sampling  samplesize <- 0.60 * nrow(data)  set.seed(80)  index <- sample( seq_len ( nrow ( data ) ), size = samplesize )  # Create training and test set  datatrain <- data[ index, ]  datatest <- data[ -index, ]
  • 10. Fitting Neural Network  We fit a neural network on our data. We use ”neuralnet” library for the analysis.  The common techniques to scale data are: min-max normalization, Z- score normalization, median and MAD, and tan-h estimators. The min-max normalization transforms the data into a common range, thus removing the scaling effect from all the variables.  We use min-max normalization to scale the data.
  • 11. R Script  ## Scale data for neural network  max = apply(data , 2 , max) min = apply(data, 2 , min)  scaled = as.data.frame(scale(data, center = min, scale = max - min))
  • 12. # install library install.packages("neuralnet ") # load library library(neuralnet) # creating training and test set trainNN = scaled[index , ] testNN = scaled[-index , ]
  • 13.  # fit neural network  set.seed(2)  NN = neuralnet(rating ~ calories + protein + fat + sodium + fiber, trainNN, hidden = 3 , linear.output = T )  # plot neural network  plot(NN)