Perform the training step of the localised multiple kernel k-means.
lmkkmeans(Km, parameters, verbose = FALSE)
Km | An array of size N x N x M containing M different N x N kernel matrices. |
---|---|
parameters | A list of parameters containing the desired number of
clusters, |
verbose | Boolean flag. If TRUE, at each iteration the iteration number is printed. Default is FALSE. |
This function returns a list containing:
the cluster labels for each element (i.e. row/column) of the kernel matrix.
the value of the objective function for the given clustering.
same parameters as in the input.
N x M matrix of weights, each row corresponds to an observation and each column to one of the kernels.
Gonen, M. and Margolin, A.A., 2014. Localized data fusion for kernel k-means clustering with application to cancer biology. In Advances in Neural Information Processing Systems (pp. 1305-1313).
if(requireNamespace("Rmosek", quietly = TRUE) && (!is.null(utils::packageDescription("Rmosek")$Configured.MSK_VERSION))){ # Initialise 100 x 100 x 3 array containing M kernel matrices # representing three different types of similarities between 100 data points km <- array(NA, c(100, 100, 3)) # Load kernel matrices km[,,1] <- as.matrix(read.csv(system.file('extdata', 'kernel_matrix1.csv', package = 'klic'), row.names = 1)) km[,,2] <- as.matrix(read.csv(system.file('extdata', 'kernel_matrix2.csv', package = 'klic'), row.names = 1)) km[,,3] <- as.matrix(read.csv(system.file('extdata', 'kernel_matrix3.csv', package = 'klic'), row.names = 1)) # Initalize the parameters of the algorithm parameters <- list() # Set the number of clusters parameters$cluster_count <- 4 # Set the number of iterations parameters$iteration_count <- 10 # Perform training state <- lmkkmeans(km, parameters) # Display the clustering print(state$clustering) # Display the kernel weights print(state$Theta) }#> [1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 #> [38] 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 #> [75] 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [,1] [,2] [,3] #> [1,] 0.4066871 0.1866257 0.4066871 #> [2,] 0.4066248 0.1867505 0.4066248 #> [3,] 0.4069210 0.1861580 0.4069210 #> [4,] 0.4065649 0.1868701 0.4065649 #> [5,] 0.4064623 0.1870755 0.4064623 #> [6,] 0.4066740 0.1866520 0.4066740 #> [7,] 0.4064532 0.1870936 0.4064532 #> [8,] 0.4069894 0.1860211 0.4069894 #> [9,] 0.4069372 0.1861257 0.4069372 #> [10,] 0.4065929 0.1868143 0.4065929 #> [11,] 0.4065555 0.1868890 0.4065555 #> [12,] 0.4066635 0.1866730 0.4066635 #> [13,] 0.4064283 0.1871434 0.4064283 #> [14,] 0.4065290 0.1869420 0.4065290 #> [15,] 0.4150902 0.1698196 0.4150902 #> [16,] 0.4065866 0.1868268 0.4065866 #> [17,] 0.4076883 0.1846234 0.4076883 #> [18,] 0.4064380 0.1871239 0.4064380 #> [19,] 0.4062025 0.1875951 0.4062025 #> [20,] 0.4063443 0.1873114 0.4063443 #> [21,] 0.4435560 0.1128879 0.4435560 #> [22,] 0.4064236 0.1871527 0.4064236 #> [23,] 0.4436630 0.1126740 0.4436630 #> [24,] 0.4064633 0.1870735 0.4064633 #> [25,] 0.4062632 0.1874737 0.4062632 #> [26,] 0.3359660 0.2824412 0.3815928 #> [27,] 0.3360494 0.2823689 0.3815817 #> [28,] 0.3346875 0.2854155 0.3798970 #> [29,] 0.3350990 0.2841497 0.3807513 #> [30,] 0.3355585 0.2831875 0.3812540 #> [31,] 0.3356937 0.2831610 0.3811454 #> [32,] 0.3347741 0.2852509 0.3799749 #> [33,] 0.3344107 0.2852842 0.3803051 #> [34,] 0.3363633 0.2821830 0.3814537 #> [35,] 0.3345492 0.2854246 0.3800262 #> [36,] 0.3340804 0.2859448 0.3799748 #> [37,] 0.3348351 0.2848885 0.3802764 #> [38,] 0.3349863 0.2850091 0.3800046 #> [39,] 0.3345966 0.2851681 0.3802353 #> [40,] 0.3350216 0.2841361 0.3808422 #> [41,] 0.3351509 0.2838918 0.3809574 #> [42,] 0.3362762 0.2824793 0.3812446 #> [43,] 0.3359393 0.2828867 0.3811741 #> [44,] 0.3441647 0.2671335 0.3887018 #> [45,] 0.3346128 0.2851719 0.3802153 #> [46,] 0.3406529 0.2740708 0.3852763 #> [47,] 0.2992359 0.3066492 0.3941149 #> [48,] 0.3350930 0.2843725 0.3805345 #> [49,] 0.3352603 0.2838617 0.3808780 #> [50,] 0.3369521 0.2811097 0.3819382 #> [51,] 0.4075357 0.2504421 0.3420222 #> [52,] 0.4071570 0.2508353 0.3420077 #> [53,] 0.4065589 0.2515709 0.3418703 #> [54,] 0.4091744 0.2495600 0.3412656 #> [55,] 0.4065905 0.2513836 0.3420258 #> [56,] 0.4601467 0.1424690 0.3973842 #> [57,] 0.4080665 0.2504276 0.3415059 #> [58,] 0.4070402 0.2507407 0.3422192 #> [59,] 0.4065388 0.2511437 0.3423174 #> [60,] 0.4105611 0.2456084 0.3438305 #> [61,] 0.3847057 0.2645033 0.3507910 #> [62,] 0.4073655 0.2522162 0.3404182 #> [63,] 0.4063891 0.2510189 0.3425920 #> [64,] 0.4054189 0.2517202 0.3428609 #> [65,] 0.4345827 0.3049675 0.2604499 #> [66,] 0.4024586 0.2534400 0.3441014 #> [67,] 0.4039574 0.2528448 0.3431977 #> [68,] 0.4308033 0.2022473 0.3669494 #> [69,] 0.4072355 0.2514256 0.3413389 #> [70,] 0.4022260 0.2542156 0.3435584 #> [71,] 0.4036579 0.2531407 0.3432015 #> [72,] 0.4074028 0.2508405 0.3417568 #> [73,] 0.4083066 0.2502825 0.3414109 #> [74,] 0.4072305 0.2508834 0.3418860 #> [75,] 0.4074041 0.2506810 0.3419149 #> [76,] 0.2737575 0.3432465 0.3829960 #> [77,] 0.2738642 0.3438923 0.3822435 #> [78,] 0.2739305 0.3436188 0.3824507 #> [79,] 0.2769142 0.3457127 0.3773731 #> [80,] 0.2791570 0.3348787 0.3859643 #> [81,] 0.2706639 0.3453036 0.3840325 #> [82,] 0.2775712 0.3373663 0.3850625 #> [83,] 0.2739370 0.3433571 0.3827058 #> [84,] 0.2138776 0.3742806 0.4118419 #> [85,] 0.2738109 0.3438340 0.3823551 #> [86,] 0.2735696 0.3440028 0.3824276 #> [87,] 0.2741196 0.3431904 0.3826900 #> [88,] 0.2737422 0.3436603 0.3825976 #> [89,] 0.2736212 0.3439577 0.3824212 #> [90,] 0.2734028 0.3438604 0.3827367 #> [91,] 0.2750903 0.3452951 0.3796146 #> [92,] 0.2734233 0.3435575 0.3830193 #> [93,] 0.2767122 0.3385746 0.3847133 #> [94,] 0.2742119 0.3430676 0.3827205 #> [95,] 0.2742497 0.3433326 0.3824177 #> [96,] 0.2736249 0.3438655 0.3825096 #> [97,] 0.2736693 0.3440552 0.3822755 #> [98,] 0.2739329 0.3437411 0.3823260 #> [99,] 0.2737391 0.3440003 0.3822606 #> [100,] 0.2738335 0.3436816 0.3824849