°øÀ¯ÀÚ·á HOME > ÀÚ·á½Ç > °øÀ¯ÀÚ·á
 
[MIS¼¼¹Ì³ª]Àΰø½Å°æ¸Á ÄÚµå ¿¹
°ü¸®ÀÚ 19-10-02 09:05 1,409
## (1) nnet ¹öÀü
library(nnet)
m<-nnet(Species~., data=iris, size=3)  
predict(m, newdata=iris)

## (2) neuralnet ¹öÀü
install.packages("neuralnet")
# creating training data set
TKS=c(20,10,30,20,80,30)
CSS=c(90,20,40,50,50,80)
Placed=c(1,0,0,0,1,1)
## À§ÀÇ ¼¼ º¤Å͸¦ ÇÑ ¸ÅÆ®¸¯½º·Î ÇÕÄ¡±â
df=data.frame(TKS,CSS,Placed)
# load library
require(neuralnet)
nn=neuralnet(Placed~TKS+CSS,data=df, hidden=3,act.fct = "logistic", linear.output = FALSE)
plot(nn)
# creating test set
TKS=c(30,40,85)
CSS=c(85,50,40)
test=data.frame(TKS,CSS)
# ÆǺ´Çϱâ
Predict=compute(nn,test)
Predict$net.result

## ÆǺ°À» binary·Î Çϱâ
prob <- Predict$net.result
pred <- ifelse(prob>0.5, 1, 0)
pred

## irisµ¥ÀÌÅͼ °¡Áö°í Çѹø ´õ ¿¬½ÀÇϱâ
nn=neuralnet(Species~.,data=iris, hidden=3,act.fct = "logistic", linear.output = FALSE)
nn
plot(nn)
## ¾Ë°í¸®ÁòÀ» ¹Ù²Ü ¼öµµ ÀÖÀ½
nn=neuralnet(Placed~TKS+CSS,data=df, hidden=3,act.fct = "logistic", linear.output = FALSE, algorithm = "backprop", learningrate=0.2)

## 'backprop' - backpropagation,
## 'rprop+' and 'rprop-' - resilient backpropagation with and without weight backtracking
## 'sag' and 'slr' - modified globally convergent algorithm (grprop).