Skip to content

A simple fix for occasional errors when using sffs #2486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/selectFeaturesSequential.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ selectFeaturesSequential = function(learner, task, resampling, measures, bit.nam
state2 = seq.step(!forward, state, gns, compare)
if (!is.null(state2)) {
state = state2
state$x = unlist(state$x)
fail = 0
} else {
fail = fail + 1
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test_featsel_selectFeaturesSequential.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
context("selectFeaturesSequential")

# This used to cause an error. Now ensure it does not.
test_that("no crash with sffs", {
p <- mlbench::mlbench.waveform(1000)
dataset <- as.data.frame(p)
dataset <- droplevels(subset(dataset, classes != 3))

mCT <- makeClassifTask(data = dataset, target = "classes")
ctrl = makeFeatSelControlSequential(method = "sffs", maxit = NA,alpha = 0.001)
mL <- makeLearner("classif.logreg", predict.type = "prob")
inner = makeResampleDesc("Holdout",stratify = TRUE)
lrn = makeFeatSelWrapper(mL, resampling = inner, control = ctrl)
outer = makeResampleDesc("CV", iters = 10,stratify = TRUE)
# No error occurs
expect_error( resample(lrn, mCT, outer, extract = getFeatSelResult,measures = list(mlr::auc,mlr::acc,mlr::brier), models=TRUE),
NA)
})