autoplot.LearnerClustHierarchical {mlr3viz} | R Documentation |
Plots for Hierarchical Clustering Learners
Description
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.
Usage
## S3 method for class 'LearnerClustHierarchical'
autoplot(
object,
type = "dend",
task = NULL,
theme = theme_minimal(),
theme_dendro = TRUE,
...
)
Arguments
object |
(mlr3cluster::LearnerClustAgnes | mlr3cluster::LearnerClustDiana | mlr3cluster::LearnerClustHclust). |
type |
(character(1)): |
task |
(mlr3::Task) |
theme |
( |
theme_dendro |
( |
... |
(ignored). |
Value
Examples
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")
}