使用遗传算法选择骨骼特征:如何提取结果?

问题描述 投票:0回答:1

我是插入式遗传算法特征选择的新手,并从对虹膜数据集的简单运行开始。我想提取最佳功能,其准确性以及模型训练的总数(功能子集的评估)。而且我不明白最终模型是如何建立的。

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

折叠是ga_ctrl中的数字,但我不确定。

为了获得最佳功能,res$optVariables是否正确?

r genetic-algorithm r-caret feature-selection
1个回答
0
投票

enter image description here我同意这两本书的文档(功能工程和应用预测)很难理解。有几个术语可以互换使用(例如,迭代与生成),这使它们都变得有些模棱两可。

PopSize是其中之一:尚不清楚它是否指代个体(染色体)的长度长度。

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.