Skip to content
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

fix(prediction): predict_time for no predictions #1159

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions R/worker.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ workhorse = function(iteration, task, learner, resampling, param_values = NULL,
lg$debug("Creating Prediction for predict set '%s'", set)
learner_predict(learner, task, row_ids)
}, set = predict_sets, row_ids = pred_data$sets, task = pred_data$tasks)

if (!length(predict_sets)) {
learner$state$predict_time = 0L
}
pdatas = discard(pdatas, is.null)

# set the model slot after prediction so it can be sent back to the main process
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test_resample.R
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,10 @@ test_that("resample results works with no predicted predict set", {
expect_list(tab$prediction, len = 1)
expect_list(tab$prediction[[1]], len = 0)
})

test_that("predict_time is 0 if no predict_set is specified", {
learner = lrn("classif.featureless", predict_sets = NULL)
rr = resample(task, learner, resampling)
times = rr$score(msr("time_predict"))$time_predict
expect_true(all(times == 0))
})