Clusters data using the OKM (Overlapping K-Means) clustering algorithm.

okm(x, centers, iter.max = 10, nstart = 1, trace = FALSE, method = "euclid")

Arguments

x

A numeric data matrix or data frame containing the data to be clustered.

centers

Either a positive integer indicating the number of clusters to create or a matrix of pre-initialized cluster centers.

iter.max

Maximum number of iterations allowed for the clustering algorithm (default is 10).

nstart

Number of random initializations to find the best result (default is 1).

trace

Logical value indicating whether to display the progress of the algorithm (default is `FALSE`).

method

A string specifying the distance metric to use; options are 'euclid' (Euclidean distance) or 'manhattan' (Manhattan distance) (default is "euclid").

Value

A list containing the clustering results, including: - `cluster`: Matrix indicating the cluster assignments for each data point. - `centers`: The final cluster centers. - `tot.withinss`: Total within-cluster sum of squares. - `overlaps`: The measure of overlap among clusters.

Examples

okm(iris[, -5], 3)
#> OKM clustering with 0 clusters of sizes:  
#> 
#> Cluster centers:
#>      Sepal.Length Sepal.Width Petal.Length Petal.Width
#> [1,]     4.570596    2.502337     2.146500   0.4472413
#> [2,]     5.325741    3.990748     1.171523   0.1606126
#> [3,]     6.615954    2.966835     5.451116   1.9291072
#> 
#> Clustering matrix:
#>        [,1] [,2] [,3]
#>   [1,]    1    1    0
#>   [2,]    1    1    0
#>   [3,]    1    1    0
#>   [4,]    1    1    0
#>   [5,]    1    1    0
#>   [6,]    0    1    0
#>   [7,]    1    1    0
#>   [8,]    1    1    0
#>   [9,]    1    1    0
#>  [10,]    1    1    0
#>  [11,]    0    1    0
#>  [12,]    1    1    0
#>  [13,]    1    1    0
#>  [14,]    1    1    0
#>  [15,]    0    1    0
#>  [16,]    0    1    0
#>  [17,]    0    1    0
#>  [18,]    1    1    0
#>  [19,]    0    1    0
#>  [20,]    0    1    0
#>  [21,]    1    1    0
#>  [22,]    1    1    0
#>  [23,]    1    1    0
#>  [24,]    1    1    0
#>  [25,]    1    1    0
#>  [26,]    1    1    0
#>  [27,]    1    1    0
#>  [28,]    1    1    0
#>  [29,]    1    1    0
#>  [30,]    1    1    0
#>  [31,]    1    1    0
#>  [32,]    1    1    0
#>  [33,]    0    1    0
#>  [34,]    0    1    0
#>  [35,]    1    1    0
#>  [36,]    1    1    0
#>  [37,]    0    1    0
#>  [38,]    1    1    0
#>  [39,]    1    1    0
#>  [40,]    1    1    0
#>  [41,]    1    1    0
#>  [42,]    1    0    0
#>  [43,]    1    1    0
#>  [44,]    1    1    0
#>  [45,]    1    1    0
#>  [46,]    1    1    0
#>  [47,]    0    1    0
#>  [48,]    1    1    0
#>  [49,]    0    1    0
#>  [50,]    1    1    0
#>  [51,]    0    0    1
#>  [52,]    0    0    1
#>  [53,]    0    0    1
#>  [54,]    1    0    1
#>  [55,]    0    0    1
#>  [56,]    1    0    1
#>  [57,]    0    0    1
#>  [58,]    1    0    1
#>  [59,]    0    0    1
#>  [60,]    1    0    1
#>  [61,]    1    0    1
#>  [62,]    1    0    1
#>  [63,]    1    0    1
#>  [64,]    0    0    1
#>  [65,]    1    0    1
#>  [66,]    0    0    1
#>  [67,]    1    0    1
#>  [68,]    1    0    1
#>  [69,]    1    0    1
#>  [70,]    1    0    1
#>  [71,]    0    0    1
#>  [72,]    1    0    1
#>  [73,]    0    0    1
#>  [74,]    1    0    1
#>  [75,]    1    0    1
#>  [76,]    0    0    1
#>  [77,]    0    0    1
#>  [78,]    0    0    1
#>  [79,]    1    0    1
#>  [80,]    1    0    1
#>  [81,]    1    0    1
#>  [82,]    1    0    1
#>  [83,]    1    0    1
#>  [84,]    0    0    1
#>  [85,]    1    0    1
#>  [86,]    1    0    1
#>  [87,]    0    0    1
#>  [88,]    1    0    1
#>  [89,]    1    0    1
#>  [90,]    1    0    1
#>  [91,]    1    0    1
#>  [92,]    1    0    1
#>  [93,]    1    0    1
#>  [94,]    1    0    1
#>  [95,]    1    0    1
#>  [96,]    1    0    1
#>  [97,]    1    0    1
#>  [98,]    1    0    1
#>  [99,]    1    0    1
#> [100,]    1    0    1
#> [101,]    0    0    1
#> [102,]    0    0    1
#> [103,]    0    0    1
#> [104,]    0    0    1
#> [105,]    0    0    1
#> [106,]    0    0    1
#> [107,]    1    0    1
#> [108,]    0    0    1
#> [109,]    0    0    1
#> [110,]    0    0    1
#> [111,]    0    0    1
#> [112,]    0    0    1
#> [113,]    0    0    1
#> [114,]    0    0    1
#> [115,]    0    0    1
#> [116,]    0    0    1
#> [117,]    0    0    1
#> [118,]    0    0    1
#> [119,]    0    0    1
#> [120,]    0    0    1
#> [121,]    0    0    1
#> [122,]    0    0    1
#> [123,]    0    0    1
#> [124,]    0    0    1
#> [125,]    0    0    1
#> [126,]    0    0    1
#> [127,]    0    0    1
#> [128,]    0    0    1
#> [129,]    0    0    1
#> [130,]    0    0    1
#> [131,]    0    0    1
#> [132,]    0    0    1
#> [133,]    0    0    1
#> [134,]    0    0    1
#> [135,]    0    0    1
#> [136,]    0    0    1
#> [137,]    0    0    1
#> [138,]    0    0    1
#> [139,]    0    0    1
#> [140,]    0    0    1
#> [141,]    0    0    1
#> [142,]    0    0    1
#> [143,]    0    0    1
#> [144,]    0    0    1
#> [145,]    0    0    1
#> [146,]    0    0    1
#> [147,]    0    0    1
#> [148,]    0    0    1
#> [149,]    0    0    1
#> [150,]    0    0    1
#> 
#> Total within-cluster sum of squares:
#> [1] 85.15571
#> 
#> Overlapping measure:
#> [1] 1.486667
#> Available components:
#> [1] "cluster"      "centers"      "tot.withinss" "overlaps"