0

I can't use graphs in clustering tasks because as_learner(graph_object) won't work for clustering learners:

Here's a reprex:

# metapackage
library(mlr3verse)

# task creation
task = TaskClust$new(
    id = "cars",
    backend = subset(
        mtcars,
        select = c(
            mpg,
            cyl,
            hp
        )
    )
)

# learner
learner = lrn("clust.kmeans")

# graph
graph = po("scale") %>>%
    po("learner", learner)

# convert graph to learner
glrn = as_learner(graph)
#> Error in .__GraphLearner__initialize(self = self, private = private, super = super, : 'graph' output type not 'Prediction' (or compatible with it)

Is there a workaround?

Obs.: I can train and predict without converting to learner, but I can't benchmark.

Alberson Miranda
  • 1,248
  • 7
  • 25
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Nov 08 '21 at 18:06
  • I don't get what you're trying to do, maybe just because I'm unfamiliar with learnr. Any reason why you can't use another benchmarking tool? – camille Nov 09 '21 at 20:04
  • @camille point is: with regression or classification, `as_learner()` works but not with clustering tasks. It also works for included tasks, as in `task = mlr_tasks$get("usarrests")` – Alberson Miranda Nov 09 '21 at 20:44
  • @MrFlick reopened – Alberson Miranda Nov 11 '21 at 12:41

0 Answers0