library(AMORE) data<-read.table('G:\\dataguru\\ML\\ML09\\基于BP网络的个人信贷信用评估\\基于BP网络的个人信贷信用评估\\german.data-numeric') for (i in 1:25) { data[,i] <- as.numeric(as.vector(data)[,i]) } pos<-data[which(data$V25=='1'),] neg<-data[which(data$V25=='2'),] train<-rbind(pos[1:350,],neg[1:150,]) test<-rbind(pos[351:700,],neg[151:300,]) net <- newff(n.neurons=c(24,8,2,1), learning.rate.global=1e-13, momentum.global=0.5, error.criterium="LMS", Stao=NA, hidden.layer="tansig", output.layer="purelin", method="ADAPTgdwm") result <- train(net, train[1:24], train[25], error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 ) y <- sim(result$net, test[1:24]) y[which(y<1.5)] <- 1 y[which(y>=1.5)] <- 2 sum = 0 for(i in 1:500){ if(y[i]==test[i,25]){ sum =sum+1 } } cat("正确率", sum/500, "n")
|
请发表评论