Closed MarcelMiche closed 2 years ago
rr = rrMap[[1]]$tuning_instance$archive$extended_archive$resample_result[[3]]
This is a ResampleResult
object with 4 iterations. It has therefore 4 Prediction
objects. You can individually score them.
rr$score()
#> task task_id learner learner_id resampling resampling_id iteration prediction regr.mse
#>1: <TaskRegr[46]> Check <LearnerRegrGlmnet[36]> regr.glmnet <ResamplingCV[19]> cv 1 <PredictionRegr[19]> 15541.300
#>2: <TaskRegr[46]> Check <LearnerRegrGlmnet[36]> regr.glmnet <ResamplingCV[19]> cv 2 <PredictionRegr[19]> 5710.667
#>3: <TaskRegr[46]> Check <LearnerRegrGlmnet[36]> regr.glmnet <ResamplingCV[19]> cv 3 <PredictionRegr[19]> 15986.089
#>4: <TaskRegr[46]> Check <LearnerRegrGlmnet[36]> regr.glmnet <ResamplingCV[19]> cv 4 <PredictionRegr[19]> 15097.602
Internally, we call rr$aggregate()
which calls mlr3measures::mse()
on each Prediction
object and then calculates the mean of the four regr.mse
scores. The result 13083.91
is logged to the archive.
You used the rr$prediction("test")
object which is the combined Prediction
object of the four resampling iterations and then you called mlr3measures::mse()
on the combined prediction result.
https://github.com/mlr-org/mlr3/commit/5cfdd9f333ddba32c918540e5d9795d9fc287be7 tries to clarify the difference.
mse() returns unexpected result when applied to a certain part of inner resampling (extended_archive$...prediction("test")), whereas returns expected result when applied to more detailed part of same inner resampling (...predictions("test")[[1]])
Date: 2022-02-09. R Version: 4.0.3 (2020-10-10). Platform: x86_64-apple-darwin17.0 (64-bit)
Setup: Using nested resampling (inner: rsmp("cv", 4), outer: rsmp("rep_cv", 2, 3)) and regr.glmnet as only learner, auto-tuning s (random search, terminate n_evals = 7), predict_sets = c("train", "test"), performance measure regr.mse. Execute: rrMap <- mlr3misc::map(as.data.table(rr)$learner, "model")
Replicable example with dummy data.
Thank you very much in advance, not just for answering, but also for your efforts put into mlr3.