Skip to content

Commit d852f38

Browse files
committed
docs(AutoFSelector): describe what hash and phash cover
The `phash` documentation was copied from `mlr3::Learner`, where the partial hash excludes the parameter values that are varied during tuning. The `AutoFSelector` has no such components, so `$phash` is deliberately identical to `$hash`, as in `mlr3tuning::AutoTuner`.
1 parent 0ba2c6f commit d852f38

3 files changed

Lines changed: 30 additions & 7 deletions

File tree

R/AutoFSelector.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ AutoFSelector = R6Class(
329329

330330
#' @field hash (`character(1)`)\cr
331331
#' Hash (unique identifier) for this object.
332+
#' Covers the id, the parameter values, the predict type, the fallback learner, the parallel predict flag,
333+
#' the [FSelector], the arguments of the [FSelectInstanceBatchSingleCrit] and the store fselect instance flag.
332334
hash = function(rhs) {
333335
assert_ro_binding(rhs)
334336
calculate_hash(
@@ -345,9 +347,10 @@ AutoFSelector = R6Class(
345347
},
346348

347349
#' @field phash (`character(1)`)\cr
348-
#' Hash (unique identifier) for this partial object,
349-
#' excluding some components which are varied systematically during tuning (parameter values)
350-
#' or feature selection (feature names).
350+
#' Hash (unique identifier) for this partial object.
351+
#' The [AutoFSelector] has no components that are varied systematically during tuning or feature selection,
352+
#' because the search space is created internally from the task.
353+
#' The partial hash is therefore deliberately identical to `$hash`.
351354
phash = function(rhs) {
352355
assert_ro_binding(rhs)
353356
self$hash

man/AutoFSelector.Rd

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_AutoFSelector.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,20 @@ test_that("instantiated resampling with foreign row ids is rejected", {
319319
expect_error(run("cv", folds = 3), "set 1 of inner resampling 'cv' contains row ids")
320320
expect_error(run("holdout"), "set 1 of inner resampling 'holdout' contains row ids")
321321
})
322+
323+
test_that("hash and phash are stable and identical", {
324+
at_1 = auto_fselector(
325+
fselector = fs("random_search", batch_size = 1),
326+
learner = lrn("classif.rpart"),
327+
resampling = rsmp("holdout"),
328+
measure = msr("classif.ce"),
329+
term_evals = 2
330+
)
331+
at_2 = at_1$clone(deep = TRUE)
332+
333+
expect_equal(at_1$hash, at_2$hash)
334+
expect_equal(at_1$phash, at_1$hash)
335+
336+
at_2$id = "other"
337+
expect_false(at_1$hash == at_2$hash)
338+
})

0 commit comments

Comments
 (0)