a-hanf / mlr3automl

Automated machine learning in mlr3
GNU Lesser General Public License v3.0
25 stars 4 forks source link

Assertion on 'ids of pipe operators' failed: Must have unique names #31

Closed MislavSag closed 2 years ago

MislavSag commented 2 years ago

When I add additional learners, very often I get following error:

Error in gunion(x) : 
  Assertion on 'ids of pipe operators' failed: Must have unique names, but element 7 is duplicated.

Sample code:

# define learners
new_params = ParamSet$new(list(
  ParamInt$new("classif.kknn.k", lower = 1, upper = 5, default = 3),
  ParamDbl$new("classif.glmnet.alpha", lower = 0, upper = 1),
  ParamInt$new("classif.nnet.size", lower = 1, upper = 10),
  ParamDbl$new("classif.nnet.decay", lower = 0, upper = 0.5)
  # ParamInt$new("classif.bart.ntree", lower = 500, upper = 1000),
  # ParamDbl$new("classif.C50.CF", lower = 0, upper = 1),
  # ParamInt$new("classif.C50.trials", lower = 1, upper = 40)
))
my_trafo = function(x, param_set) {
  if ("classif.kknn.k" %in% names(x)) {
    x[["classif.kknn.k"]] = 2^x[["classif.kknn.k"]]
  }
  return(x)
}

task_ <- tsk("iris")
bmr_results = AutoML(task_,
                     learner_list = c("classif.ranger", "classif.xgboost", "classif.liblinear",
                                      "classif.kknn", "classif.glmnet", "classif.nnet"),
                     additional_params = new_params,
                     custom_trafo=my_trafo,
                     runtime = Inf)

If I remove last learner (classif,nnet), I don't get the errors. But if I use some other learner from mlr3extralearners package, I get the same error.

a-hanf commented 2 years ago

Hi, thanks for the bug report and the example:)

I believe I found the issue (a pipeline operator with a default name of "colapply", which causes naming issues when added to the pipeline for multiple learners). You can try and install from this feature branch, this might fix your issue already: devtools::install_github('https://github.com/a-hanf/mlr3automl@bugfix_colApplyIds')

I'll have more time to properly test this on the weekend, so changes should be merged soonish.

MislavSag commented 2 years ago

I would just like to inform you that I am still getting an error.

a-hanf commented 2 years ago

Does this happen when you reload the package from the bugfix_colApplyIds feature branch? I can repro on master, but it's fixed on the branch. Will test a bit and merge later today or tomorrow

a-hanf commented 2 years ago

Changes merged to master, can you please try again?

MislavSag commented 2 years ago

I can't install the package:

devtools::install_github('https://github.com/a-hanf/mlr3automl')

I get error:

Downloading GitHub repo a-hanf/mlr3automl@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

 1: All                                   
 2: CRAN packages only                    
 3: None                                  
 4: utf8         (1.2.1  -> 1.2.2 ) [CRAN]
 5: pillar       (1.6.1  -> 1.6.2 ) [CRAN]
 6: tibble       (3.1.2  -> 3.1.4 ) [CRAN]
 7: cli          (3.0.0  -> 3.0.1 ) [CRAN]
 8: lgr          (0.4.2  -> 0.4.3 ) [CRAN]
 9: bbotk        (0.3.2  -> 0.4.0 ) [CRAN]
10: waldo        (0.2.5  -> 0.3.1 ) [CRAN]
11: pkgload      (1.2.1  -> 1.2.2 ) [CRAN]
12: stringi      (1.6.2  -> 1.7.4 ) [CRAN]
13: mlr3tuning   (0.8.0  -> 0.9.0 ) [CRAN]
14: ranger       (0.12.1 -> 0.13.1) [CRAN]
15: testthat     (3.0.3  -> 3.0.4 ) [CRAN]
16: mlr3hyper... (0.1.2  -> 0.2.0 ) [CRAN]
17: mlr3learners (0.4.5  -> 0.5.0 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 3
√  checking for file 'C:\Users\Mislav\AppData\Local\Temp\RtmpSeypqL\remotes5cace71158\a-hanf-mlr3automl-0a0d8c7/DESCRIPTION'
-  preparing 'mlr3automl':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'mlr3automl_0.0.0.9000.tar.gz'

Installing package into ‘C:/Users/Mislav/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
* installing *source* package 'mlr3automl' ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'mlr3automl'
    finding HTML links ... done
    AutoML                                  html  
    finding level-2 HTML links ... done

    AutoMLBase                              html  
Error: C:/Users/Mislav/AppData/Local/Temp/Rtmpk5ZbEt/R.INSTALL525c20d746c5/mlr3automl/man/AutoMLBase.Rd:271: Bad \link text
* removing 'C:/Users/Mislav/Documents/R/win-library/4.1/mlr3automl'
* restoring previous 'C:/Users/Mislav/Documents/R/win-library/4.1/mlr3automl'
Warning messages:
1: replacing previous import ‘zoo::index’ by ‘exuber::index’ when loading ‘mlfinance’ 
2: In i.p(...) :
  installation of package ‘C:/Users/Mislav/AppData/Local/Temp/RtmpSeypqL/file5cac285a6cde/mlr3automl_0.0.0.9000.tar.gz’ had non-zero exit status
a-hanf commented 2 years ago

Should work now, sorry for the inconvenience. Let me know how it goes