遗传算法在R。随机森林模型中的应用

时间:2014-04-01 11:31:50

标签: r genetic-algorithm random-forest

我是R的新手,我想将随机森林模型应用于遗传算法,我在R.my Code中使用(GA)包

library(GA)

library(randomForest)

library(Hmisc)

data<-read.csv("norm.csv")

d=sort(sample(nrow(data),nrow(data)*.7))

train=data[d,]

test=data[-d,]

y<-train$Readmission

fitness <- function(string) {

  inc <- which(string == 1)

  x<- cbind(1, train[,inc])

  testing<-cbind(1,test[inc])

  mod<-randomForest(x,y)

  pr<-predict(mod,testing,type="raw")

  cst<-(somers2(pr,test$Readmission))


  return(cst)

}

GA <- ga("binary", fitness = fitness, nBits = ncol(train),
         names = colnames(train), monitor = plot,maxiter = 10)

plot(GA)

summary(GA)

如何分析解决方案....谢谢..

0 个答案:

没有答案