【问题标题】:Carets Feature Selection using Genetic Algorithms: How to extract the results?使用遗传算法的插入符号特征选择:如何提取结果?
【发布时间】:2019-11-11 13:42:01
【问题描述】:

我是插入符号遗传算法特征选择的新手,并从对 iris 数据集的简单运行开始。我想提取最佳特征、它们的准确性以及模型训练的总数(特征子集的评估)。此外,我不明白最终模型是如何构建的。

Caret 提供了该方法的描述:https://topepo.github.io/caret/feature-selection-using-genetic-algorithms.html 但是,我并不真正了解他们最终需要多少次模型训练,以及最终模型是如何构建的。

library(caret) 

dataset <- iris
levels(dataset$Species) <- c(0, 0, 1)

ga_ctrl <- gafsControl(functions = caretGA, method = "cv", number = 3, verbose = TRUE)
res <- caret::gafs(x = dataset[, 1:(length(dataset)-1)], 
 y = dataset[, length(dataset)],
 iters = 5,
 popSize = 6,
 pcrossover = 0.8,
 pmutation = 0.1,
 gafsControl = ga_ctrl,
 method = "glm", family = binomial(link = 'logit'),
 trControl = trainControl(method = "cv"))

我得到了这个输出(现在没有设置特定的种子):

Fold1 1 0.96 (2)
Fold1 2 0.96->0.97 (2->4, 50.0%) *
Fold1 3 0.97->0.9788889 (4->2, 50.0%) *
Fold1 4 0.9788889->0.9809091 (2->2, 100.0%) *
Fold1 5 0.9809091->0.98 (2->2, 100.0%)
Fold2 1 0.9718182 (3)
Fold2 2 0.9718182->0.9709091 (3->4, 75.0%)
Fold2 3 0.9718182->0.9718182 (3->4, 75.0%)
Fold2 4 0.9718182->0.9709091 (3->1, 33.3%)
Fold2 5 0.9718182->0.9688889 (3->3, 50.0%)
Fold3 1 0.97 (3)
Fold3 2 0.97->0.9688889 (3->3, 100.0%)
Fold3 3 0.97->0.97 (3->3, 100.0%)
Fold3 4 0.97->0.969798 (3->2, 66.7%)
Fold3 5 0.97->0.9709091 (3->3, 100.0%) *
+ final GA
 1 0.9533333 (1)
 2 0.9533333->0.96 (1->2, 50.0%) *
 3 0.96->0.9533333 (2->2, 100.0%)
 4 0.96->0.98 (2->3, 66.7%) *
 5 0.98->0.9733333 (3->3, 100.0%)
+ final model

res$ga$fit 的准确度为 0.96,res$fit 的准确度为 0.9533333,但 0.98 应该是正确的值,不是吗?

对于培训的总数,我想是这样的

popSize * iters * folds

folds 是来自 ga_ctrl 的数字,但我不确定。

对于最佳功能,res$optVariables 是否正确?

【问题讨论】:

    标签: r genetic-algorithm r-caret feature-selection


    【解决方案1】:

    我同意这两本书(特征工程和应用预测)的文档很难理解。有几个术语可以互换使用(例如迭代与生成),这使得它有点模棱两可。

    PopSize 就是其中之一:不清楚它是指个体(染色体)的数量还是

    我相信 popSize 是指种群的初始大小(个体/染色体的数量)。我不确定下一代(也称为迭代)是否会一遍又一遍地拥有这 50 个人。如果是这样,那么你的计算应该是正确的。

    $optVariables 应该存储最好的变量。您还可以(可能)在最终模型中找到它们。 我正在运行 PLS,我可以在 MODEL$fit$finalModel$xNames 上找到它们

    最终 GA 针对您数据集上的所有观察结果运行。

    【讨论】:

      猜你喜欢
      • 2019-06-12
      • 1970-01-01
      • 1970-01-01
      • 2012-02-06
      • 1970-01-01
      • 2011-12-21
      • 2016-04-26
      • 2014-02-01
      • 2016-01-02
      相关资源
      最近更新 更多