mlr3 icon indicating copy to clipboard operation
mlr3 copied to clipboard

nicer error message or better default for id in as_task_<xx> when id is not given

Open mb706 opened this issue 1 year ago • 0 comments

as_task_classif(data.frame(x = factor(c("a", "b", "a", "b"), levels = c("a", "b")), y = factor(c("a", "b", "a", "b"), levels = c("a", "b"))), target = "y")
#> Error in .__Task__initialize(self = self, private = private, super = super,  : 
#>   Assertion on 'id' failed: Must have length 1.

this is because id is created from the expression of the data argument. I would vote for creating a nicer, shorter version of the id, possibly incorporating a hash of the entire string, e.g.

data.frame.x...fac.35d82fge

in cases where we can't create the id the straightforward way, but even if not a more informative error message would help

mb706 avatar Jul 15 '23 18:07 mb706