Generates plots for mlr3cluster::PredictionClust, depending on argument type:

  • "scatter" (default): scatterplot with correlation values and colored cluster assignments.

  • "sil": Silhouette plot with mean silhouette value as a reference line.

  • "pca": Perform PCA on data and color code cluster assignments. Inspired by and uses ggfortify::autoplot.kmeans.

# S3 method for PredictionClust
autoplot(object, task, row_ids = NULL, type = "scatter", ...)

Arguments

object

(mlr3cluster::PredictionClust).

task

(mlr3cluster::TaskClust).

row_ids

row ids to subset task data to ensure that only the data used to make predictions are shown in plots.

type

(character(1)):
Type of the plot. See description.

...

(any): Additional arguments, passed down to the respective geom.

Value

ggplot2::ggplot() object.

Examples

library(mlr3) library(mlr3cluster) library(mlr3viz) task = tsk("usarrests") learner = lrn("clust.kmeans", centers = 3) object = learner$train(task)$predict(task) head(fortify(object))
#> row_id partition #> 1: 1 3 #> 2: 2 3 #> 3: 3 3 #> 4: 4 2 #> 5: 5 3 #> 6: 6 2
autoplot(object, task)
#> Registered S3 method overwritten by 'GGally': #> method from #> +.gg ggplot2
#> Warning: Factor variables are omitted in plot