View source: R/LearnerClustHierarchical.R
autoplot.LearnerClustHierarchical | R Documentation |
Visualizations for hierarchical clusters.
The argument type
controls what kind of plot is drawn.
Possible choices are:
"dend"
(default): Dendrograms using ggdendro package.
"scree"
: Scree plot that shows the number of possible clusters on the x-axis and the height on the y-axis.
## S3 method for class 'LearnerClustHierarchical'
autoplot(
object,
type = "dend",
task = NULL,
theme = theme_minimal(),
theme_dendro = TRUE,
...
)
object |
(mlr3cluster::LearnerClustAgnes | mlr3cluster::LearnerClustDiana | mlr3cluster::LearnerClustHclust). |
type |
(character(1)): |
task |
(mlr3::Task) |
theme |
( |
theme_dendro |
( |
... |
(ignored). |
ggplot2::ggplot()
.
if (requireNamespace("mlr3")) {
library(mlr3)
library(mlr3cluster)
library(mlr3viz)
task = tsk("usarrests")
# agnes clustering
learner = lrn("clust.agnes")
learner$train(task)
autoplot(learner)
# diana clustering
learner = lrn("clust.diana")
learner$train(task)
autoplot(learner)
# hclust clustering
learner = lrn("clust.hclust")
learner$train(task)
autoplot(learner, type = "scree")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.