View source: R/PredictionClust.R
autoplot.PredictionClust | R Documentation |
Visualizations for mlr3cluster::PredictionClust.
The argument type
controls what kind of plot is drawn.
Possible choices are:
"scatter"
(default): scatterplot with correlation values and colored cluster assignments.
"sil"
: Silhouette plot with mean silhouette value as the reference line.
Requires package ggfortify.
"pca"
: Perform PCA on data and color code cluster assignments.
Inspired by and uses ggfortify::autoplot.kmeans.
## S3 method for class 'PredictionClust'
autoplot(
object,
task,
row_ids = NULL,
type = "scatter",
theme = theme_minimal(),
...
)
object |
(mlr3cluster::PredictionClust). |
task |
(mlr3cluster::TaskClust). |
row_ids |
( |
type |
(character(1)): |
theme |
( |
... |
(ignored). |
ggplot2::ggplot()
.
Tang Y, Horikoshi M, Li W (2016). “ggfortify: Unified Interface to Visualize Statistical Result of Popular R Packages.” The R Journal, 8(2), 474–485. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/RJ-2016-060")}.
if (requireNamespace("mlr3")) {
library(mlr3)
library(mlr3cluster)
library(mlr3viz)
task = tsk("usarrests")
learner = lrn("clust.kmeans", centers = 3)
object = learner$train(task)$predict(task)
head(fortify(object))
autoplot(object, task)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.