如何正确使用遗传算法进行预测

mql*_*ner 8 r genetic-algorithm

我正在尝试使用遗传算法进行分类问题.但是,我没有成功获得模型的摘要,也没有预测新的数据框.如何获取新数据集的摘要和预测?这是我的玩具示例:

library(genalg)
dat <- read.table(text = " cats birds    wolfs     snakes
                  0        3        9         7
                  1        3        8         7
                  1        1        2         3
                  0        1        2         3
                  0        1        2         3
                  1        6        1         1
                  0        6        1         1
                  1        6        1         1   ", header = TRUE) 
evalFunc <- function(x) {
        if (dat$cats < 1) 
        return(0) else return(1)
}
iter = 100
GAmodel <- rbga.bin(size = 7, popSize = 200, iters = iter, mutationChance = 0.01, 
                    elitism = T, evalFunc = evalFunc)

###########summary try#############

cat(summary.rbga(GAmodel))
# Error in cat(summary.rbga(GAmodel)) : 
#   could not find function "summary.rbga"

############# prediction try###########

dat$pred<-predict(GAmodel,newdata=dat)
# Error in UseMethod("predict") : 
#   no applicable method for 'predict' applied to an object of class "rbga"
Run Code Online (Sandbox Code Playgroud)

更新:阅读给出的答案并阅读此链接: 使用遗传算法进行模式预测 我想知道如何以编程方式将GA用作预测机制的一部分?根据链接的文本,可以使用GA来优化回归或NN,然后使用它们提供的预测函数/

G5W*_*G5W 4

遗传算法 是为了优化,而不是为了分类。因此,没有预测方法。你的总结陈述即将生效。

cat(summary(GAmodel))
GA Settings
  Type                  = binary chromosome
  Population size       = 200
  Number of Generations = 100
  Elitism               = TRUE
  Mutation Chance       = 0.01

Search Domain
  Var 1 = [,]
  Var 0 = [,]

GA Results
  Best Solution : 1 1 0 0 0 0 1 
Run Code Online (Sandbox Code Playgroud)

伦敦帝国理工学院提供了一些其他信息

更新响应更新的问题:

我从你提到的论文中看到这是有道理的。其想法是使用遗传算法来优化神经网络的权重,然后使用神经网络进行分类。这将是一项艰巨的任务,太大了,无法在这里做出回应。