selected_vars <- safs_initial(vars = 10 , prob = 0.2)
selected_vars
###
safs_perturb(selected_vars, vars = 10, number = 1)
###
safs_prob(old = .8, new = .9, iteration = 1)
safs_prob(old = .5, new = .6, iteration = 1)
grid <- expand.grid(old = c(4, 3.5),
new = c(4.5, 4, 3.5) + 1,
iter = 1:40)
grid <- subset(grid, old < new)
grid$prob <- apply(grid, 1,
function(x)
safs_prob(new = x["new"],
old= x["old"],
iteration = x["iter"]))
grid$Difference <- factor(grid$new - grid$old)
grid$Group <- factor(paste("Current Value", grid$old))
ggplot(grid, aes(x = iter, y = prob, color = Difference)) +
geom_line() + facet_wrap(~Group) + theme_bw() +
ylab("Probability") + xlab("Iteration")
## Not run:
# ###
# ## Hypothetical examples
# lda_sa <- safs(x = predictors,
# y = classes,
# safsControl = safsControl(functions = caretSA),
# ## now pass arguments to `train`
# method = "lda",
# metric = "Accuracy"
# trControl = trainControl(method = "cv", classProbs = TRUE))
#
# rf_sa <- safs(x = predictors,
# y = classes,
# safsControl = safsControl(functions = rfSA),
# ## these are arguments to `randomForest`
# ntree = 1000,
# importance = TRUE)
# ## End(Not run)
Run the code above in your browser using DataLab