Skip to contents

A LearnerClust for divisive hierarchical clustering implemented in cluster::diana(). The predict method uses stats::cutree() which cuts the tree resulting from hierarchical clustering into specified number of groups (see parameter k). The default value for k is 2.

Dictionary

This mlr3::Learner can be instantiated via the dictionary mlr3::mlr_learners or with the associated sugar function mlr3::lrn():

mlr_learners$get("clust.diana")
lrn("clust.diana")

Meta Information

  • Task type: “clust”

  • Predict Types: “partition”

  • Feature Types: “logical”, “integer”, “numeric”

  • Required Packages: mlr3, mlr3cluster, cluster

Parameters

IdTypeDefaultLevelsRange
metriccharactereuclideaneuclidean, manhattan-
standlogicalFALSETRUE, FALSE-
trace.levinteger0\([0, \infty)\)
kinteger2\([1, \infty)\)

References

Kaufman, Leonard, Rousseeuw, J P (2009). Finding groups in data: an introduction to cluster analysis. John Wiley & Sons.

Super classes

mlr3::Learner -> mlr3cluster::LearnerClust -> LearnerClustDiana

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClustDiana$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner and set parameter values
learner = lrn("clust.diana")
print(learner)
#> 
#> ── <LearnerClustDiana> (clust.diana): Divisive Hierarchical Clustering ─────────
#> • Model: -
#> • Parameters: k=2
#> • Packages: mlr3, mlr3cluster, and cluster
#> • Predict Types: [partition]
#> • Feature Types: logical, integer, and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties: complete, exclusive, and hierarchical
#> • Other settings: use_weights = 'error'

# Define a Task
task = tsk("usarrests")

# Train the learner on the task
learner$train(task)

# Print the model
print(learner$model)
#> Merge:
#>       [,1] [,2]
#>  [1,]  -15  -29
#>  [2,]  -17  -26
#>  [3,]  -14  -16
#>  [4,]  -13  -32
#>  [5,]  -35  -44
#>  [6,]  -46  -50
#>  [7,]   -7  -38
#>  [8,]  -19  -41
#>  [9,]  -36  -47
#> [10,]    1  -49
#> [11,]  -21  -30
#> [12,]   -4  -42
#> [13,]    8  -48
#> [14,]  -34  -45
#> [15,]  -22  -28
#> [16,]   -3  -31
#> [17,]   -6  -43
#> [18,]   -1  -18
#> [19,]  -37    6
#> [20,]    2  -27
#> [21,]    3   20
#> [22,]   16  -20
#> [23,]   18   -8
#> [24,]    7    5
#> [25,]   10  -23
#> [26,]  -12   21
#> [27,]    4   15
#> [28,]    9   19
#> [29,]   17  -10
#> [30,]   11  -39
#> [31,]   -2  -24
#> [32,]   24   26
#> [33,]  -25   28
#> [34,]   22   -5
#> [35,]   12   29
#> [36,]   30   33
#> [37,]   23   27
#> [38,]   -9  -33
#> [39,]   25   14
#> [40,]   34  -40
#> [41,]   37   31
#> [42,]  -11   39
#> [43,]   42   13
#> [44,]   32   36
#> [45,]   41   35
#> [46,]   40   38
#> [47,]   44   43
#> [48,]   45   46
#> [49,]   48   47
#> Order of objects:
#>  [1]  1 18  8 13 32 22 28  2 24  4 42  6 43 10  3 31 20  5 40  9 33  7 38 35 44
#> [26] 12 14 16 17 26 27 21 30 39 25 36 47 37 46 50 11 15 29 49 23 34 45 19 41 48
#> Height:
#>  [1]  15.454449  16.976749  37.430469   6.236986  22.366046  13.297368
#>  [7]  47.627933  28.635118  77.884530  12.614278  36.734861  14.501034
#> [13]  25.093027 150.045593  13.896043  15.890249  36.347352  47.061343
#> [19]  80.332123  38.527912 293.622751   8.027453  18.264994   6.637771
#> [25]  31.477135  19.904271   3.929377  15.766420   3.834058  15.766420
#> [31]  77.453083  11.456439  26.343880  36.847931  33.570821  10.305338
#> [37]  23.349518  15.630099   7.930952 137.516726  51.919264   2.291288
#> [43]  10.860018  19.437592  41.784447  13.044922  57.271022   8.537564
#> [49]  12.775367
#> Divisive coefficient:
#> [1] 0.9464692
#> 
#> Available components:
#> [1] "order"  "height" "dc"     "merge"  "diss"   "call"   "data"  

# Make predictions for the task
prediction = learner$predict(task)
#> Warning: Learner 'clust.diana' doesn't predict on new data and predictions may not make sense on new data.

# Score the predictions
prediction$score(task = task)
#> clust.dunn 
#>  0.1033191