Skip to contents

Fuzzy c-means clustering. Calls e1071::cmeans() from package e1071.

The centers parameter is set to 2 by default since e1071::cmeans() doesn't have a default value for the number of clusters. The predict method uses clue::cl_predict() to compute the cluster memberships for new data.

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.cmeans")
lrn("clust.cmeans")

Meta Information

  • Task type: “clust”

  • Predict Types: “partition”, “prob”

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

  • Required Packages: mlr3, mlr3cluster, e1071, clue

Parameters

IdTypeDefaultLevelsRange
centersuntyped--
iter.maxinteger100\([1, \infty)\)
verboselogicalFALSETRUE, FALSE-
distcharactereuclideaneuclidean, manhattan-
methodcharactercmeanscmeans, ufcl-
mnumeric2\([1, \infty)\)
rate.parnumeric-\([0, 1]\)
weightsuntyped1L-
controluntyped--

References

Dimitriadou, Evgenia, Hornik, Kurt, Leisch, Friedrich, Meyer, David, Weingessel, Andreas (2008). “Misc functions of the Department of Statistics (e1071), TU Wien.” R package, 1, 5–24.

Bezdek, C J (2013). Pattern recognition with fuzzy objective function algorithms. Springer Science & Business Media.

Super classes

mlr3::Learner -> mlr3cluster::LearnerClust -> LearnerClustCMeans

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

LearnerClustCMeans$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner and set parameter values
learner = lrn("clust.cmeans")
print(learner)
#> 
#> ── <LearnerClustCMeans> (clust.cmeans): Fuzzy C-Means ──────────────────────────
#> • Model: -
#> • Parameters: centers=2
#> • Packages: mlr3, mlr3cluster, e1071, and clue
#> • Predict Types: [partition] and prob
#> • Feature Types: logical, integer, and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties: complete, fuzzy, and partitional
#> • 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)
#> Fuzzy c-means clustering with 2 clusters
#> 
#> Cluster centers:
#>    Assault    Murder     Rape UrbanPop
#> 1 256.7369 11.647605 28.07208 68.53657
#> 2 105.4689  4.833035 15.99985 62.72022
#> 
#> Memberships:
#>                  1           2
#>  [1,] 0.9667196532 0.033280347
#>  [2,] 0.9724276916 0.027572308
#>  [3,] 0.9590341205 0.040965880
#>  [4,] 0.6005501286 0.399449871
#>  [5,] 0.9670405328 0.032959467
#>  [6,] 0.7773569306 0.222643069
#>  [7,] 0.0112913433 0.988708657
#>  [8,] 0.9699588189 0.030041181
#>  [9,] 0.8946006839 0.105399316
#> [10,] 0.8380297405 0.161970259
#> [11,] 0.0814522229 0.918547777
#> [12,] 0.0151669346 0.984833065
#> [13,] 0.9865766200 0.013423380
#> [14,] 0.0044405434 0.995559457
#> [15,] 0.0579320510 0.942067949
#> [16,] 0.0052596968 0.994740303
#> [17,] 0.0067506852 0.993249315
#> [18,] 0.9944984642 0.005501536
#> [19,] 0.0226079200 0.977392080
#> [20,] 0.9530450037 0.046954996
#> [21,] 0.1653843355 0.834615665
#> [22,] 0.9964126463 0.003587354
#> [23,] 0.0319972461 0.968002754
#> [24,] 0.9698612008 0.030138799
#> [25,] 0.4688288801 0.531171120
#> [26,] 0.0048546611 0.995145339
#> [27,] 0.0005410356 0.999458964
#> [28,] 0.9785251264 0.021474874
#> [29,] 0.0569296046 0.943070395
#> [30,] 0.2616638263 0.738336174
#> [31,] 0.9755348920 0.024465108
#> [32,] 0.9862692125 0.013730787
#> [33,] 0.8831759151 0.116824085
#> [34,] 0.0818425370 0.918157463
#> [35,] 0.0206878795 0.979312121
#> [36,] 0.1583179904 0.841682010
#> [37,] 0.2417176835 0.758282317
#> [38,] 0.0038982106 0.996101789
#> [39,] 0.4115696602 0.588430340
#> [40,] 0.9695723749 0.030427625
#> [41,] 0.0229398372 0.977060163
#> [42,] 0.5927263139 0.407273686
#> [43,] 0.7468753489 0.253124651
#> [44,] 0.0287390105 0.971260990
#> [45,] 0.0862932857 0.913706714
#> [46,] 0.2017646347 0.798235365
#> [47,] 0.1236471848 0.876352815
#> [48,] 0.0361916547 0.963808345
#> [49,] 0.0625575558 0.937442444
#> [50,] 0.2473612426 0.752638757
#> 
#> Closest hard clustering:
#>  [1] 1 1 1 1 1 1 2 1 1 1 2 2 1 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 2 2 1 1 1 2 2 2 2 2
#> [39] 2 1 2 1 1 2 2 2 2 2 2 2
#> 
#> Available components:
#> [1] "centers"     "size"        "cluster"     "membership"  "iter"       
#> [6] "withinerror" "call"       

# Make predictions for the task
prediction = learner$predict(task)

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