task <- makeClassifTask(data=iris, target="Species")
lrn <- makeLearner("classif.rpart")
rdesc <- makeResampleDesc("Holdout")
## Now create control-objects for each of the possible feature selection algorithms:
ctrlSeq <- makeFeatSelControlSequential(method="sfs", maxit=NA)
ctrlGA <- makeFeatSelControlGA(maxit=5, max.features=NA, crossover.rate=0.5,
mutation.rate=0.1, mu=10, lambda=5)
ctrlRand <- makeFeatSelControlRandom(maxit=10, max.features=NA, prob=0.5)
ctrlExh <- makeFeatSelControlExhaustive(maxit=NA, max.features=NA)
## Let's run the feature selction algorithm:
sfSeq <- selectFeatures(lrn, task, rdesc, control=ctrlSeq)
sfSeq
sfGA <- selectFeatures(lrn, task, rdesc, control=ctrlGA)
sfGA
sfRand <- selectFeatures(lrn, task, rdesc, control=ctrlRand)
sfRand
sfExh <- selectFeatures(lrn, task, rdesc, control=ctrlExh)
sfExh
Run the code above in your browser using DataLab