mlr-org / mlr3

mlr3: Machine Learning in R - next generation
https://mlr3.mlr-org.com
GNU Lesser General Public License v3.0
914 stars 84 forks source link

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

Open mb706 opened 1 year ago

mb706 commented 1 year ago
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