How to get Training of Neural Networks
library(MASS)library(nnet)
set.seed(123)
DataFrame <- Boston
help("Boston")
View(DataFrame)
str(DataFrame)
> View(DataFrame)
> str(DataFrame)
'data.frame': 506 obs. of 14 variables:
$ crim : num 0.00632 0.02731 0.02729 0.03237 0.06905 ...
$ zn : num 18 0 0 0 0 0 12.5 12.5 12.5 12.5 ...
$ indus : num 2.31 7.07 7.07 2.18 2.18 2.18 7.87 7.87 7.87 7.87 ...
$ chas : int 0 0 0 0 0 0 0 0 0 0 ...
$ nox : num 0.538 0.469 0.469 0.458 0.458 0.458 0.524 0.524 0.524 0.524 ...
$ rm : num 6.58 6.42 7.18 7 7.15 ...
$ age : num 65.2 78.9 61.1 45.8 54.2 58.7 66.6 96.1 100 85.9 ...
$ dis : num 4.09 4.97 4.97 6.06 6.06 ...
$ rad : int 1 2 2 3 3 3 5 5 5 5 ...
$ tax : num 296 242 242 222 222 222 311 311 311 311 ...
$ ptratio: num 15.3 17.8 17.8 18.7 18.7 18.7 15.2 15.2 15.2 15.2 ...
$ black : num 397 397 393 395 397 ...
$ lstat : num 4.98 9.14 4.03 2.94 5.33 ...
$ medv : num 24 21.6 34.7 33.4 36.2 28.7 22.9 27.1 16.5 18.9
hist(DataFrame$medv)
apply(DataFram, 2,range)
appply(DataFrame,2,range)
maxValue<- apply(DataFrame, 2, max)
minValue <- apply(DataFrame, 2,min)
DataFrame <- as.data.frame(scale(DataFrame,center = minValue,scale = maxValue))
ind<-sample(1:nrow(DataFrame),400)
trainDF <- DataFrame [ind ,]
testDF <-DataFrame[-ind,]
allVars <- colnames(DataFrame)
predictorVars <- paste(predictorVars,collapse = "+")
form=as.formula(paste("medv~",predictorVars,collapse = "+"))
neuralModel<- nnet(formula =form, hidden = c(4,2.linear.output = T,data =trainDF))
plot(neuralModel)
1 Comments
Machine Learning is a wide area of Artificial Intelligence focused in the design and development of an algorithm that identifies and learn patterns exist in data provided as input. machine learning course
ReplyDelete