基于遗传算法的R特征选择

时间:2017-12-26 14:55:33

标签: r genetic-algorithm feature-selection

我正在尝试使用R的Caret包为特征选择问题编写遗传算法。 我测试了下面的代码(使用随机森林作为健身功能)。有用。 我可以更改什么才能使其与其他模型(SVM或LDA)一起使用?

library(dplyr)
library(doParallel)
library(randomForest)

ga_ctrl <- gafsControl(functions = rfGA, # Assess fitness with RF
                       method = "cv",   # 10 fold cross validation
                       genParallel=TRUE, # Use parallel programming
                       allowParallel = TRUE
)


lev <- c("0", "1")     # Set the levels

set.seed(27)
system.time( model_1 <- gafs(x = hill_train, y = hill_train$class,
                             iters = 100, # generations of algorithm
                             popSize = 50, # population size for each generation
                             pcrossover = 0.8,
                             pmutation = 0.001,
                             levels = lev,
                             gafsControl = ga_ctrl))
plot(model_1) # Plot mean fitness (AUC) by generation

mm_hill <- model_1$ga$final

0 个答案:

没有答案
相关问题