mlr-org / mlr3

mlr3: Machine Learning in R - next generation
https://mlr3.mlr-org.com
GNU Lesser General Public License v3.0
927 stars 86 forks source link

`iters` field of Resampling should probably not be writable? #923

Closed jemus42 closed 1 week ago

jemus42 commented 1 year ago

Description

I was surprised to learn that the iters field was writable for e.g. a holdout Resampling, which you can (counter-intuitively?) use to construct a makeshift subsampling. The other way around does not work, which I guess is fine.

Reproducible example

library(mlr3)

holdout = rsmp("holdout")
holdout$iters = 30
holdout
#> <ResamplingHoldout>: Holdout
#> * Iterations: 30
#> * Instantiated: FALSE
#> * Parameters: ratio=0.6667

subsampling = rsmp("subsampling")
subsampling$iters = 1
#> Error in assert_ro_binding(rhs): Field/Binding is read-only

Created on 2023-04-25 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.3 (2023-03-15) #> os macOS Ventura 13.3.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2023-04-25 #> pandoc 2.19.2 @ /System/Volumes/Data/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> ! package * version date (UTC) lib source #> P backports 1.4.1 2021-12-13 [?] CRAN (R 4.2.0) #> P checkmate 2.1.0 2022-04-21 [?] CRAN (R 4.2.0) #> P cli 3.6.1 2023-03-23 [?] CRAN (R 4.2.3) #> P codetools 0.2-19 2023-02-01 [?] CRAN (R 4.2.0) #> P crayon 1.5.2 2022-09-29 [?] CRAN (R 4.2.0) #> P data.table 1.14.8 2023-02-17 [?] CRAN (R 4.2.0) #> P digest 0.6.31 2022-12-11 [?] CRAN (R 4.2.0) #> P evaluate 0.20 2023-01-17 [?] CRAN (R 4.2.0) #> P fastmap 1.1.1 2023-02-24 [?] CRAN (R 4.2.0) #> P fs 1.6.1 2023-02-06 [?] CRAN (R 4.2.0) #> P future 1.32.0 2023-03-07 [?] CRAN (R 4.2.0) #> P globals 0.16.2 2022-11-21 [?] CRAN (R 4.2.0) #> P glue 1.6.2 2022-02-24 [?] CRAN (R 4.2.0) #> P htmltools 0.5.5 2023-03-23 [?] CRAN (R 4.2.3) #> P knitr 1.42 2023-01-25 [?] CRAN (R 4.2.0) #> P lgr 0.4.4 2022-09-05 [?] CRAN (R 4.2.0) #> P lifecycle 1.0.3 2022-10-07 [?] CRAN (R 4.2.0) #> P listenv 0.9.0 2022-12-16 [?] CRAN (R 4.2.0) #> P magrittr 2.0.3 2022-03-30 [?] CRAN (R 4.2.0) #> P mlr3 * 0.15.0 2023-03-17 [?] CRAN (R 4.2.0) #> P mlr3misc 0.11.0 2022-09-22 [?] CRAN (R 4.2.0) #> P palmerpenguins 0.1.1 2022-08-15 [?] CRAN (R 4.2.0) #> P paradox 0.11.1 2023-03-17 [?] CRAN (R 4.2.0) #> P parallelly 1.35.0 2023-03-23 [?] CRAN (R 4.2.0) #> P purrr 1.0.1 2023-01-10 [?] CRAN (R 4.2.0) #> P R.cache 0.16.0 2022-07-21 [?] CRAN (R 4.2.0) #> P R.methodsS3 1.8.2 2022-06-13 [?] CRAN (R 4.2.0) #> P R.oo 1.25.0 2022-06-12 [?] CRAN (R 4.2.0) #> P R.utils 2.12.2 2022-11-11 [?] CRAN (R 4.2.0) #> P R6 2.5.1 2021-08-19 [?] CRAN (R 4.2.0) #> P reprex 2.0.2 2022-08-17 [?] CRAN (R 4.2.0) #> P rlang 1.1.0 2023-03-14 [?] CRAN (R 4.2.0) #> P rmarkdown 2.21 2023-03-26 [?] CRAN (R 4.2.3) #> P rstudioapi 0.14 2022-08-22 [?] CRAN (R 4.2.0) #> P sessioninfo 1.2.2 2021-12-06 [?] CRAN (R 4.2.0) #> P styler 1.9.1 2023-03-04 [?] CRAN (R 4.2.0) #> P uuid 1.1-0 2022-04-19 [?] CRAN (R 4.2.0) #> P vctrs 0.6.2 2023-04-19 [?] CRAN (R 4.2.0) #> P withr 2.5.0 2022-03-03 [?] CRAN (R 4.2.0) #> P xfun 0.39 2023-04-20 [?] CRAN (R 4.2.0) #> P yaml 2.3.7 2023-01-23 [?] CRAN (R 4.2.0) #> #> [1] /Users/Lukas/Library/Caches/R/renv/book-d8af5e07/R-4.2/aarch64-apple-darwin20 #> [2] /Users/Lukas/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.2/aarch64-apple-darwin20/fd29d0b8 #> [3] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library #> #> P ── Loaded and on-disk path mismatch. #> #> ────────────────────────────────────────────────────────────────────────────── ```