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

pos in combination with as_graph leads to unexpected ids #718

Open sebffischer opened 1 year ago

sebffischer commented 1 year ago
library(mlr3pipelines)
as_graph(pos(c("pca", "ica")))
#> Graph with 2 PipeOps:
#>       ID         State sccssors prdcssors
#>  pca.pca <<UNTRAINED>>                   
#>  ica.ica <<UNTRAINED>>

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

mb706 commented 1 year ago

I think as_graph does the sensible thing here: if a named list is given, it uses the names as prefix. This makes it possible to do things like

as_graph(list(a = po("nop"), b = po("nop")))
#> Graph with 2 PipeOps:
#>     ID         State sccssors prdcssors
#>  a.nop <<UNTRAINED>>                   
#>  b.nop <<UNTRAINED>>    

without ID collisions.

We could argue that pos() should not use the IDs as names for the generated list. Why are we doing that again?