mlr-org / mlr3pipelines

Dataflow Programming for Machine Learning in R
https://mlr3pipelines.mlr-org.com/
GNU Lesser General Public License v3.0
137 stars 25 forks source link

build phash recursively #719

Closed mb706 closed 1 year ago

mb706 commented 1 year ago
library(mlr3pipelines)
library(mlr3verse)
#> Loading required package: mlr3

learner1 = as_learner(ppl("robustify") %>>% lrn("regr.rpart"))
learner2 = as_learner(po("pca") %>>% lrn("regr.rpart"))

learner1$id = "myid"
learner2$id = "myid"

learner1$phash
#> [1] "c4a0875e498289b1"
learner2$phash
#> [1] "c4a0875e498289b1"

reported by @sebffischer

mb706 commented 1 year ago

Contrary to what the comment says, this has nothing to do with feature names (?) and only takes out the param_set$values from the hash. From here:

    #' @template field_hash
    hash = function(rhs) {
      assert_ro_binding(rhs)
      calculate_hash(class(self), self$id, self$param_set$values, private$.predict_type,
        self$fallback$hash, self$parallel_predict)
    },

    #' @field phash (`character(1)`)\cr
    #' Hash (unique identifier) for this partial object, excluding some components
    #' which are varied systematically during tuning (parameter values) or feature
    #' selection (feature names).
    phash = function(rhs) {
      assert_ro_binding(rhs)
      calculate_hash(class(self), self$id, private$.predict_type,
        self$fallback$hash, self$parallel_predict)
    },