R Neural Networks - Weights -
i have error message when use weights in nnet() though package documentation says weights. however, if use wts works. suppose weight defaults 1 if don't enter value.
regardless of wts value enter nnet() return weights = 83 , how 83 weights assigned ?. please @ output below:
i suppose don't understand how these weights assigned
any appreciated. thank you.
attach(iris) library(caret) set.seed(3456) trainindex <- createdatapartition(iris$species, p = .8, list = f, times = 1) iristrain <- iris[ trainindex,] iristest <- iris[-trainindex,] irispred <- nnet(species ~ ., data=iristrain ,weights = 1, size=10) predicted <- predict(irispred,iristest,type="class")
error when using weights (package documentations says use weights)
irispred <- nnet(species ~ ., data=iristrain ,weights = 1, size=10) error in model.frame.default(formula = species ~ ., data = iristrain, : variable lengths differ (found '(weights)')
no error if use wts:
irispred <- nnet(species ~ ., data=iristrain ,wts = 1, size=10) # weights: 83 initial value 148.744330 iter 10 value 20.508558 iter 20 value 7.683385 iter 30 value 5.719438 iter 40 value 3.831845 iter 50 value 3.524789 iter 60 value 3.461561 iter 70 value 3.352866 iter 80 value 3.061214 iter 90 value 3.049519 iter 100 value 3.001406 final value 3.001406 stopped after 100 iterations irispred$wts [1] 0.46982680904 -1.08944343286 -0.85761073123 -2.05356837297 -1.56599897345 [6] 291.18284632141 31.85356741288 27.37999662827 -97.45738049129 -55.50299935575 [11] -1.36175718738 .......up 83. > irispred <- nnet(species ~ ., data=iristrain ,wts = 28, size=10) # weights: 83 initial value 143.546315 iter 10 value 55.502915 iter 20 value 40.514073 iter 30 value 6.610363 iter 40 value 6.111119 iter 50 value 6.019070 iter 60 value 5.963004 iter 70 value 5.956329 iter 80 value 5.945786 iter 90 value 5.942088 iter 100 value 5.939509 final value 5.939509 stopped after 100 iterations > irispred$wts [1] 1.07816704818 1.89161925466 1.36901821472 -0.39336454435 -0.23879356006 [6] -0.63780061885 -2.62845406757 ... 83