How to subset a PredictionClust/Prediction/R6 object

Viewed 38

I have a clustering task with about 500k datapoints. I want to plot the clusters but my machine can't handle an autoplot() with that amount of data. What are the alternatives?

Is it possible to plot only the contours or maybe subset the prediction object for plotting?

1 Answers

Did you try to use the row_ids argument of autoplot()? You can plot a subset of your predictions with it. This could still fail with large data but maybe it is works on your machine.

library(mlr3)
library(mlr3cluster)
library(mlr3viz)

task = mlr_tasks$get("usarrests")
learner = mlr_learners$get("clust.kmeans")
learner$train(task)
preds = learner$predict(task = task)

row_ids = sample(preds$row_ids, 10)
autoplot(preds, task, row_ids = row_ids)
Related