Redes neuronales en R

Se utilizan 6 variables (V2, V3, V4, V5,V6, V7) para predecir si a un cliente se le otorga una tarjeta de crédito (0: No, 1,: Si). Se predice la  probabilidad mediante redes neuronales.


mues<-sample(1:nrow(datos),round(0.7*nrow(datos)))
entrena<-datos[mues,]
entrena
test<-datos[-mues,]
test

cre <- neuralnet(V1~V2+V3+V4+V5+V6+V7,
hidden=c(4,1),entrena, act.fct="tanh",threshold = 0.1,linear.output = T )
cre


Call: neuralnet(formula = V1 ~ V2 + V3 + V4 + V5 + V6 + V7, data = entrena,     hidden = c(4, 1), threshold = 0.1, act.fct = "tanh", linear.output = T)

1 repetition was calculated.

        Error Reached Threshold Steps

1 18.53080727     0.07014630452   251

cre$result.matrix
plot(cre, rep = "best")














summary(cre)

                   Length Class      Mode    
call                   7   -none-     call    
response             245   -none-     numeric 
covariate           1470   -none-     numeric 
model.list             2   -none-     list    
err.fct                1   -none-     function
act.fct                1   -none-     function
linear.output          1   -none-     numeric 
data                   7   data.frame list    
net.result             1   -none-     list    
weights                1   -none-     list    
startweights           1   -none-     list    
generalized.weights    1   -none-     list    

result.matrix         38   -none-     numeric 

prueb<-subset(test,select=c("V2","V3","V4","V5","V6","V7"))
prueb
cretres<-compute(cre,prueb)
cretres

resu<- data.frame(actual = test$V1, 
prediction = cretres$net.resu)
resu

resul$prediction<-round(resul$prediction)
resul$prediction
resul
tabla5<-table(resul)
tabla5

       prediction
actual  0  1
     0 43  3

     1 40 31

sum(diag(tabla5))/sum(tabla5)



 0.6324786325

No hay comentarios.:

Publicar un comentario