R Under development (unstable) (2023-11-26 r85638 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(cluster) > > ## generate 1500 objects, divided into 2 clusters. > suppressWarnings(RNGversion("3.5.0")) # << as long as we don't have R >= 3.6.0 > set.seed(144) > x <- rbind(cbind(rnorm(700, 0,8), rnorm(700, 0,8)), + cbind(rnorm(800,50,8), rnorm(800,10,8))) > > isEq <- function(x,y, epsF = 100) + is.logical(r <- all.equal(x,y, tol = epsF * .Machine$double.eps)) && r > > .proctime00 <- proc.time() > > ## full size sample {should be = pam()}: > n0 <- length(iSml <- c(1:70, 701:720)) > summary(clara0 <- clara(x[iSml,], k = 2, sampsize = n0)) Object of class 'clara' from call: clara(x = x[iSml, ], k = 2, sampsize = n0) Medoids: [,1] [,2] [1,] -1.499522 -1.944452 [2,] 48.629631 12.998515 Objective function: 10.23588 Numerical information per cluster: size max_diss av_diss isolation [1,] 70 24.81995 10.25745 0.4744879 [2,] 20 19.07782 10.16040 0.3647145 Average silhouette width per cluster: [1] 0.7144587 0.7090915 Average silhouette width of best sample: 0.713266 Best sample: [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [76] 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Clustering vector: [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 1 1 1 1 1 1 1 1 1 1 1 1 1 [39] 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 1 1 1 1 1 1 2 2 2 2 2 2 [77] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Silhouette plot information for best sample: cluster neighbor sil_width 45 1 2 0.8033727 60 1 2 0.8021017 55 1 2 0.8005931 66 1 2 0.8002776 58 1 2 0.7991899 11 1 2 0.7991773 41 1 2 0.7973302 26 1 2 0.7962397 63 1 2 0.7962229 13 1 2 0.7949705 67 1 2 0.7942590 54 1 2 0.7936184 17 1 2 0.7916087 16 1 2 0.7913570 39 1 2 0.7912755 6 1 2 0.7840455 34 1 2 0.7833568 49 1 2 0.7819733 9 1 2 0.7789087 23 1 2 0.7785009 32 1 2 0.7757325 22 1 2 0.7655369 61 1 2 0.7639754 12 1 2 0.7639644 5 1 2 0.7606436 18 1 2 0.7579145 56 1 2 0.7566307 3 1 2 0.7537894 24 1 2 0.7531180 50 1 2 0.7517817 48 1 2 0.7501998 25 1 2 0.7499655 59 1 2 0.7472022 19 1 2 0.7445038 65 1 2 0.7398395 28 1 2 0.7377377 38 1 2 0.7370935 7 1 2 0.7335940 40 1 2 0.7310012 14 1 2 0.7294895 62 1 2 0.7254478 70 1 2 0.7163214 4 1 2 0.7157257 21 1 2 0.7148663 64 1 2 0.7108496 2 1 2 0.7062831 15 1 2 0.7015120 52 1 2 0.6978313 37 1 2 0.6954023 31 1 2 0.6932905 33 1 2 0.6888478 10 1 2 0.6805028 20 1 2 0.6766854 43 1 2 0.6761461 8 1 2 0.6749706 27 1 2 0.6671817 35 1 2 0.6632888 68 1 2 0.6587599 30 1 2 0.6554989 36 1 2 0.6228481 53 1 2 0.6203313 57 1 2 0.6191666 42 1 2 0.6142020 47 1 2 0.6024151 1 1 2 0.5814464 69 1 2 0.5091186 46 1 2 0.4961302 44 1 2 0.4849961 29 1 2 0.4569316 51 1 2 0.4230181 81 2 1 0.7965942 71 2 1 0.7961971 85 2 1 0.7919593 74 2 1 0.7869047 82 2 1 0.7795304 78 2 1 0.7788873 79 2 1 0.7729041 72 2 1 0.7492980 88 2 1 0.7447973 87 2 1 0.7404399 76 2 1 0.7352351 77 2 1 0.7216838 86 2 1 0.7165677 84 2 1 0.6952406 73 2 1 0.6942882 83 2 1 0.6621568 80 2 1 0.6368446 90 2 1 0.5743228 75 2 1 0.5597232 89 2 1 0.4482549 4005 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 0.1865 11.5850 20.0580 27.8150 45.5780 85.2320 Metric : euclidean Number of objects : 90 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > pam0 <- pam (x[iSml,], k = 2) > stopifnot(identical(clara0$clustering, pam0$clustering) + , isEq(clara0$objective, unname(pam0$objective[2])) + ) > > summary(clara2 <- clara(x, 2)) Object of class 'clara' from call: clara(x = x, k = 2) Medoids: [,1] [,2] [1,] 2.012828 -1.896095 [2,] 51.494628 10.274769 Objective function: 10.23445 Numerical information per cluster: size max_diss av_diss isolation [1,] 700 36.84408 10.49814 0.7230478 [2,] 800 30.89896 10.00373 0.6063775 Average silhouette width per cluster: [1] 0.7562366 0.7203254 Average silhouette width of best sample: 0.733384 Best sample: [1] 21 23 50 97 142 168 191 192 197 224 325 328 433 458 471 [16] 651 712 714 722 797 805 837 909 919 926 999 1006 1018 1019 1049 [31] 1081 1084 1132 1144 1150 1201 1207 1250 1291 1307 1330 1374 1426 1428 Clustering vector: [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 1 1 1 1 1 1 1 1 1 1 1 1 [38] 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 1 1 1 1 1 1 1 1 1 1 1 [75] 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 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1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2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1111] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1148] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1185] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1222] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1259] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1296] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1333] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1370] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1407] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1444] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [1481] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Silhouette plot information for best sample: cluster neighbor sil_width 325 1 2 0.8261589 191 1 2 0.8206687 23 1 2 0.8149640 97 1 2 0.8048084 433 1 2 0.8017745 458 1 2 0.8008324 471 1 2 0.7958547 328 1 2 0.7689099 142 1 2 0.7619508 21 1 2 0.7607528 197 1 2 0.7606641 50 1 2 0.7509131 192 1 2 0.7098473 651 1 2 0.7035969 224 1 2 0.6843886 168 1 2 0.5337006 1084 2 1 0.8180447 1081 2 1 0.8171686 1201 2 1 0.8170847 1291 2 1 0.8167148 1307 2 1 0.8166841 1144 2 1 0.8159947 999 2 1 0.8135303 1426 2 1 0.8023538 1049 2 1 0.8022891 1250 2 1 0.8014300 712 2 1 0.7859324 837 2 1 0.7792784 1018 2 1 0.7764837 919 2 1 0.7651939 1374 2 1 0.7648534 1428 2 1 0.7516819 1330 2 1 0.7505861 1006 2 1 0.7368113 714 2 1 0.7237565 1150 2 1 0.7046060 1132 2 1 0.6940608 909 2 1 0.6859682 926 2 1 0.6725631 722 2 1 0.6572791 797 2 1 0.6395698 1019 2 1 0.6083662 805 2 1 0.2814164 1207 2 1 0.2694097 946 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 0.4846 12.3230 26.4990 32.2130 52.3910 77.1750 Metric : euclidean Number of objects : 44 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > > clInd <- c("objective", "i.med", "medoids", "clusinfo") > clInS <- c(clInd, "sample") > ## clara() {as original code} always draws the *same* random samples !!!! > clara(x, 2, samples = 50)[clInd] $objective [1] 10.06735 $i.med [1] 177 1115 $medoids [,1] [,2] [1,] -0.2538744 -1.209148 [2,] 50.0372683 9.501125 $clusinfo size max_diss av_diss isolation [1,] 700 34.67208 10.193945 0.6743054 [2,] 800 29.51964 9.956571 0.5741003 > for(i in 1:20) + print(clara(x[sample(nrow(x)),], 2, samples = 50)[clInd]) $objective [1] 10.05727 $i.med [1] 936 192 $medoids [,1] [,2] [1,] 50.03726827 9.501124850 [2,] -0.03900399 -0.009078886 $clusinfo size max_diss av_diss isolation [1,] 800 29.51964 9.956571 0.5791419 [2,] 700 34.06055 10.172348 0.6682295 $objective [1] 10.05296 $i.med [1] 468 1394 $medoids [,1] [,2] [1,] -0.3292826 -0.2398794 [2,] 50.0372683 9.5011249 $clusinfo size max_diss av_diss isolation [1,] 700 33.98451 10.163128 0.6624677 [2,] 800 29.51964 9.956571 0.5754330 $objective [1] 10.05852 $i.med [1] 1171 379 $medoids [,1] [,2] [1,] 50.9444060 9.6723175 [2,] -0.3292826 -0.2398794 $clusinfo size max_diss av_diss isolation [1,] 800 30.10388 9.966988 0.5764486 [2,] 700 33.98451 10.163128 0.6507574 $objective [1] 10.07051 $i.med [1] 75 1254 $medoids [,1] [,2] [1,] -0.9493373 0.3552542 [2,] 50.5455985 9.3904972 $clusinfo size max_diss av_diss isolation [1,] 700 33.12704 10.191999 0.6336273 [2,] 800 29.66384 9.964205 0.5673860 $objective [1] 10.0613 $i.med [1] 199 134 $medoids [,1] [,2] [1,] -0.03900399 -0.009078886 [2,] 49.59384120 9.792964832 $clusinfo size max_diss av_diss isolation [1,] 700 34.06055 10.172348 0.6732466 [2,] 800 29.57491 9.964138 0.5845827 $objective [1] 10.06101 $i.med [1] 1453 1122 $medoids [,1] [,2] [1,] 50.0372683 9.50112485 [2,] -0.9691441 0.03342515 $clusinfo size max_diss av_diss isolation [1,] 800 29.51964 9.956571 0.5690241 [2,] 700 33.31923 10.180359 0.6422655 $objective [1] 10.08603 $i.med [1] 613 318 $medoids [,1] [,2] [1,] 50.0627056 9.478225 [2,] -0.2902194 1.026496 $clusinfo size max_diss av_diss isolation [1,] 800 29.51131 9.957225 0.5780037 [2,] 700 33.21560 10.233240 0.6505552 $objective [1] 10.07293 $i.med [1] 618 406 $medoids [,1] [,2] [1,] 50.3621263 9.0207185 [2,] -0.2092816 -0.5916053 $clusinfo size max_diss av_diss isolation [1,] 800 29.25143 9.990206 0.5682446 [2,] 700 34.30301 10.167473 0.6663777 $objective [1] 10.0592 $i.med [1] 1279 1349 $medoids [,1] [,2] [1,] 50.1502433 10.60358224 [2,] -0.9691441 0.03342515 $clusinfo size max_diss av_diss isolation [1,] 800 30.54975 9.953191 0.5852356 [2,] 700 33.31923 10.180359 0.6382900 $objective [1] 10.06241 $i.med [1] 1293 21 $medoids [,1] [,2] [1,] 50.5809098 9.7418386 [2,] -0.9493373 0.3552542 $clusinfo size max_diss av_diss isolation [1,] 800 29.98892 9.949013 0.5725461 [2,] 700 33.12704 10.191999 0.6324587 $objective [1] 10.0592 $i.med [1] 337 675 $medoids [,1] [,2] [1,] -0.9691441 0.03342515 [2,] 50.1502433 10.60358224 $clusinfo size max_diss av_diss isolation [1,] 700 33.31923 10.180359 0.6382900 [2,] 800 30.54975 9.953191 0.5852356 $objective [1] 10.05697 $i.med [1] 22 574 $medoids [,1] [,2] [1,] 50.5809098 9.74183863 [2,] -0.9691441 0.03342515 $clusinfo size max_diss av_diss isolation [1,] 800 29.98892 9.949013 0.5716937 [2,] 700 33.31923 10.180359 0.6351809 $objective [1] 10.05096 $i.med [1] 739 808 $medoids [,1] [,2] [1,] 50.5809098 9.7418386 [2,] -0.2092816 -0.5916053 $clusinfo size max_diss av_diss isolation [1,] 800 29.98892 9.949013 0.5785936 [2,] 700 34.30301 10.167473 0.6618278 $objective [1] 10.06135 $i.med [1] 1431 485 $medoids [,1] [,2] [1,] 50.0627056 9.47822525 [2,] -0.9691441 0.03342515 $clusinfo size max_diss av_diss isolation [1,] 800 29.51131 9.957225 0.5686352 [2,] 700 33.31923 10.180359 0.6420076 $objective [1] 10.05324 $i.med [1] 10 1221 $medoids [,1] [,2] [1,] 50.58090982 9.741838628 [2,] -0.03900399 -0.009078886 $clusinfo size max_diss av_diss isolation [1,] 800 29.98892 9.949013 0.5817385 [2,] 700 34.06055 10.172348 0.6607218 $objective [1] 10.06101 $i.med [1] 1249 1411 $medoids [,1] [,2] [1,] -0.9691441 0.03342515 [2,] 50.0372683 9.50112485 $clusinfo size max_diss av_diss isolation [1,] 700 33.31923 10.180359 0.6422655 [2,] 800 29.51964 9.956571 0.5690241 $objective [1] 10.05296 $i.med [1] 610 21 $medoids [,1] [,2] [1,] -0.3292826 -0.2398794 [2,] 50.0372683 9.5011249 $clusinfo size max_diss av_diss isolation [1,] 700 33.98451 10.163128 0.6624677 [2,] 800 29.51964 9.956571 0.5754330 $objective [1] 10.06486 $i.med [1] 1101 397 $medoids [,1] [,2] [1,] -0.9691441 0.03342515 [2,] 50.1066826 9.35514422 $clusinfo size max_diss av_diss isolation [1,] 700 33.31923 10.180359 0.6417479 [2,] 800 29.42336 9.963794 0.5667111 $objective [1] 10.07521 $i.med [1] 838 356 $medoids [,1] [,2] [1,] 50.36212634 9.020718482 [2,] -0.03900399 -0.009078886 $clusinfo size max_diss av_diss isolation [1,] 800 29.25143 9.990206 0.5712766 [2,] 700 34.06055 10.172348 0.6651980 $objective [1] 10.05906 $i.med [1] 1270 1024 $medoids [,1] [,2] [1,] 50.5455985 9.3904972 [2,] -0.2092816 -0.5916053 $clusinfo size max_diss av_diss isolation [1,] 800 29.66384 9.964205 0.5734673 [2,] 700 34.30301 10.167473 0.6631526 > > clara(x, 2, samples = 101)[clInd] $objective [1] 10.05727 $i.med [1] 286 1115 $medoids [,1] [,2] [1,] -0.03900399 -0.009078886 [2,] 50.03726827 9.501124850 $clusinfo size max_diss av_diss isolation [1,] 700 34.06055 10.172348 0.6682295 [2,] 800 29.51964 9.956571 0.5791419 > clara(x, 2, samples = 149)[clInd] $objective [1] 10.05319 $i.med [1] 238 1272 $medoids [,1] [,2] [1,] -0.2092816 -0.5916053 [2,] 50.1502433 10.6035822 $clusinfo size max_diss av_diss isolation [1,] 700 34.30301 10.167473 0.6649301 [2,] 800 30.54975 9.953191 0.5921768 > clara(x, 2, samples = 200)[clInd] $objective [1] 10.05319 $i.med [1] 238 1272 $medoids [,1] [,2] [1,] -0.2092816 -0.5916053 [2,] 50.1502433 10.6035822 $clusinfo size max_diss av_diss isolation [1,] 700 34.30301 10.167473 0.6649301 [2,] 800 30.54975 9.953191 0.5921768 > ## Note that this last one is practically identical to the slower pam() one > > (ii <- sample(length(x), 20)) [1] 249 452 2663 2537 2235 2421 1004 1834 2602 397 717 2805 1575 1281 283 [16] 1657 1749 820 269 519 > ## This was bogous (and lead to seg.faults); now properly gives error. > ## but for these, now see ./clara-NAs.R > if(FALSE) { ## ~~~~~~~~~~~~~ + x[ii] <- NA + try( clara(x, 2, samples = 50) ) + } > > ###-- Larger example: 2000 objects, divided into 5 clusters. > x5 <- rbind(cbind(rnorm(400, 0,4), rnorm(400, 0,4)), + cbind(rnorm(400,10,8), rnorm(400,40,6)), + cbind(rnorm(400,30,4), rnorm(400, 0,4)), + cbind(rnorm(400,40,4), rnorm(400,20,2)), + cbind(rnorm(400,50,4), rnorm(400,50,4))) > ## plus 1 random dimension > x5 <- cbind(x5, rnorm(nrow(x5))) > > clara(x5, 5) Call: clara(x = x5, k = 5) Medoids: [,1] [,2] [,3] [1,] 0.5850466 -2.222194 -0.63631241 [2,] 8.0131143 42.708122 -0.31693240 [3,] 42.6657812 21.123133 -0.62411426 [4,] 50.6470292 48.480686 -0.09146223 [5,] 28.6470950 -2.544131 -0.22186047 Objective function: 6.100721 Clustering vector: int [1:2000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 400 396 408 401 395 Best sample: [1] 23 130 178 202 267 297 338 357 376 387 439 441 638 647 662 [16] 719 723 802 874 880 994 1038 1056 1097 1184 1215 1225 1268 1271 1282 [31] 1346 1442 1446 1474 1496 1515 1585 1590 1605 1641 1680 1687 1696 1728 1742 [46] 1761 1857 1909 1951 1956 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > summary(clara(x5, 5, samples = 50)) Object of class 'clara' from call: clara(x = x5, k = 5, samples = 50) Medoids: [,1] [,2] [,3] [1,] -0.8427864 0.1606105 -0.70362181 [2,] 12.0389703 39.0303445 0.19158023 [3,] 39.6341676 20.7182868 0.43978514 [4,] 50.6470292 48.4806864 -0.09146223 [5,] 30.6814242 -0.1072177 -0.25861548 Objective function: 5.743812 Numerical information per cluster: size max_diss av_diss isolation [1,] 400 15.20728 5.207177 0.4823345 [2,] 397 24.25898 8.677062 0.7324727 [3,] 406 18.39064 4.369617 0.8109074 [4,] 401 18.28050 5.260543 0.6119680 [5,] 396 12.69653 5.243478 0.5598344 Average silhouette width per cluster: [1] 0.7433532 0.6956424 0.7315944 0.7336104 0.7079360 Average silhouette width of best sample: 0.7188531 Best sample: [1] 106 130 145 213 275 316 434 444 486 501 630 693 713 739 773 [16] 804 808 821 823 899 914 948 961 972 980 987 1076 1114 1126 1127 [31] 1169 1175 1203 1225 1228 1242 1269 1397 1405 1421 1595 1606 1658 1703 1777 [46] 1834 1857 1881 1937 1999 Clustering vector: [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 1 1 1 1 1 1 1 1 1 1 1 1 [38] 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 1 1 1 1 1 1 1 1 1 1 1 [75] 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 1 1 1 1 1 1 1 1 1 1 1 [112] 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 1 1 1 1 1 1 1 1 1 1 1 [149] 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 1 1 1 1 1 1 1 1 1 1 1 [186] 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 1 1 1 1 1 1 1 1 1 1 1 [223] 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 1 1 1 1 1 1 1 1 1 1 1 [260] 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 1 1 1 1 1 1 1 1 1 1 1 [297] 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 1 1 1 1 1 1 1 1 1 1 1 [334] 1 1 1 1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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1814] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1851] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1888] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1925] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1962] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [1999] 4 4 Silhouette plot information for best sample: cluster neighbor sil_width 130 1 5 0.8123353 275 1 5 0.7945197 316 1 5 0.7561799 213 1 5 0.7459412 106 1 5 0.6869957 145 1 5 0.6641473 630 2 3 0.7819320 739 2 3 0.7774128 486 2 3 0.7559683 713 2 3 0.7316982 444 2 3 0.7204625 501 2 3 0.7091146 773 2 1 0.6886472 693 2 3 0.5855803 434 2 3 0.5099654 1225 3 5 0.8105776 1203 3 5 0.7965773 1595 3 5 0.7842711 1269 3 5 0.7799931 1242 3 5 0.7625442 1397 3 5 0.7315512 1228 3 5 0.7262025 1421 3 5 0.6011616 1405 3 5 0.5914707 1999 4 3 0.8050046 1857 4 3 0.8030709 1658 4 3 0.7941141 1777 4 3 0.7865209 1937 4 3 0.7831996 1881 4 3 0.7504779 1834 4 3 0.6614223 1606 4 3 0.6373808 1703 4 3 0.5813025 804 5 3 0.8021043 987 5 3 0.7999064 1076 5 3 0.7907769 948 5 3 0.7905304 961 5 3 0.7716289 823 5 3 0.7657693 808 5 3 0.7510670 914 5 3 0.7358231 1175 5 3 0.7337485 1169 5 3 0.7254812 972 5 3 0.7118795 821 5 3 0.7101558 899 5 1 0.6580927 1114 5 3 0.6552887 1127 5 3 0.6292428 1126 5 3 0.5362475 980 5 1 0.4671695 1225 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 0.6968 19.3160 34.0920 33.0700 46.2540 92.2530 Metric : euclidean Number of objects : 50 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > ## 3 "half" samples: > clara(x5, 5, samples = 999) Call: clara(x = x5, k = 5, samples = 999) Medoids: [,1] [,2] [,3] [1,] 0.2143499 0.3891695 0.45577894 [2,] 10.9779485 39.6788652 -0.23487762 [3,] 40.2944064 20.2221253 0.21417849 [4,] 50.7170411 49.7645642 -0.43318939 [5,] 29.7257398 -0.5981739 -0.05616701 Objective function: 5.659041 Clustering vector: int [1:2000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 400 397 407 401 395 Best sample: [1] 1 2 103 147 155 176 179 247 262 288 365 369 372 470 486 [16] 573 759 779 785 791 797 822 875 883 913 954 1107 1114 1154 1156 [31] 1171 1175 1206 1213 1218 1233 1243 1394 1439 1444 1512 1741 1777 1798 1800 [46] 1818 1845 1946 1948 1973 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > clara(x5, 5, samples = 1000) Call: clara(x = x5, k = 5, samples = 1000) Medoids: [,1] [,2] [,3] [1,] 0.2143499 0.3891695 0.45577894 [2,] 10.9779485 39.6788652 -0.23487762 [3,] 40.2944064 20.2221253 0.21417849 [4,] 50.7170411 49.7645642 -0.43318939 [5,] 29.7257398 -0.5981739 -0.05616701 Objective function: 5.659041 Clustering vector: int [1:2000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 400 397 407 401 395 Best sample: [1] 1 2 103 147 155 176 179 247 262 288 365 369 372 470 486 [16] 573 759 779 785 791 797 822 875 883 913 954 1107 1114 1154 1156 [31] 1171 1175 1206 1213 1218 1233 1243 1394 1439 1444 1512 1741 1777 1798 1800 [46] 1818 1845 1946 1948 1973 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > clara(x5, 5, samples = 1001) Call: clara(x = x5, k = 5, samples = 1001) Medoids: [,1] [,2] [,3] [1,] 0.2143499 0.3891695 0.45577894 [2,] 10.9779485 39.6788652 -0.23487762 [3,] 40.2944064 20.2221253 0.21417849 [4,] 50.7170411 49.7645642 -0.43318939 [5,] 29.7257398 -0.5981739 -0.05616701 Objective function: 5.659041 Clustering vector: int [1:2000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 400 397 407 401 395 Best sample: [1] 1 2 103 147 155 176 179 247 262 288 365 369 372 470 486 [16] 573 759 779 785 791 797 822 875 883 913 954 1107 1114 1154 1156 [31] 1171 1175 1206 1213 1218 1233 1243 1394 1439 1444 1512 1741 1777 1798 1800 [46] 1818 1845 1946 1948 1973 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > > clara(x5, 5, samples = 2000)#full sample Call: clara(x = x5, k = 5, samples = 2000) Medoids: [,1] [,2] [,3] [1,] 0.2143499 0.3891695 0.45577894 [2,] 10.5993345 39.8970536 -0.39199265 [3,] 40.3370139 20.3148331 -0.06033818 [4,] 50.7170411 49.7645642 -0.43318939 [5,] 29.7257398 -0.5981739 -0.05616701 Objective function: 5.65785 Clustering vector: int [1:2000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 400 397 407 401 395 Best sample: [1] 84 106 164 226 284 288 329 423 430 450 469 593 603 654 742 [16] 887 929 970 974 1035 1043 1096 1171 1187 1192 1302 1307 1327 1371 1431 [31] 1433 1439 1440 1452 1513 1522 1525 1548 1565 1593 1620 1639 1654 1688 1740 [46] 1761 1832 1845 1895 1899 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > > ###--- Start a version of example(clara) ------- > > ## xclara : artificial data with 3 clusters of 1000 bivariate objects each. > data(xclara) > (clx3 <- clara(xclara, 3)) Call: clara(x = xclara, k = 3) Medoids: V1 V2 [1,] 5.553391 13.306260 [2,] 43.198760 60.360720 [3,] 74.591890 -6.969018 Objective function: 13.225 Clustering vector: int [1:3000] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Cluster sizes: 900 1148 952 Best sample: [1] 20 30 46 91 92 169 179 187 209 223 382 450 555 971 1004 [16] 1025 1058 1277 1281 1302 1319 1361 1362 1513 1591 1623 1628 1729 1752 1791 [31] 1907 1917 1946 2064 2089 2498 2527 2537 2545 2591 2672 2722 2729 2790 2797 [46] 2852 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > ## Plot similar to Figure 5 in Struyf et al (1996) > plot(clx3) > > ## The rngR = TRUE case is currently in the non-strict tests > ## ./clara-ex.R > ## ~~~~~~~~~~~~ > > ###--- End version of example(clara) ------- > > ## small example(s): > data(ruspini) > > clara(ruspini,4) Call: clara(x = ruspini, k = 4) Medoids: x y 10 19 65 32 44 149 52 99 119 67 66 18 Objective function: 11.51066 Clustering vector: Named int [1:75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... - attr(*, "names")= chr [1:75] "1" "2" "3" "4" "5" "6" "7" ... Cluster sizes: 20 23 17 15 Best sample: [1] 2 3 4 5 6 7 8 9 10 16 18 19 20 21 22 23 25 29 30 32 34 35 36 37 41 [26] 42 43 44 46 47 49 50 52 53 54 58 59 60 61 63 65 66 67 69 71 72 73 75 Available components: [1] "sample" "medoids" "i.med" "clustering" "objective" [6] "clusinfo" "diss" "call" "silinfo" "data" > > rus <- data.matrix(ruspini); storage.mode(rus) <- "double" > ru2 <- rus[c(1:7,21:28, 45:51, 61:69),] > ru3 <- rus[c(1:4,21:25, 45:48, 61:63),] > ru4 <- rus[c(1:2,21:22, 45:47),] > ru5 <- rus[c(1:2,21, 45),] > daisy(ru5, "manhattan") Dissimilarities : 1 2 21 2 11 21 118 107 45 143 132 89 Metric : manhattan Number of objects : 4 > ## Dissimilarities : 11 118 143 107 132 89 > > ## no problem anymore, since 2002-12-28: > ## sampsize >= k+1 is now enforced: > ## clara(ru5, k=3, met="manhattan", sampsize=3,trace=2)[clInS] > clara(ru5, k=3, met="manhattan", sampsize=4,trace=1)[clInS] C clara(): (nsam,nran,n) = (4,5,4); 'full_sample', -> dysta2(); obj= 2.75 resul(), black() and return() from C. $objective [1] 2.75 $i.med [1] 2 3 4 $medoids x y 2 5 63 21 28 147 45 85 115 $clusinfo size max_diss av_diss isolation [1,] 2 11 5.5 0.1028037 [2,] 1 0 0.0 0.0000000 [3,] 1 0 0.0 0.0000000 $sample [1] "1" "2" "21" "45" > > daisy(ru4, "manhattan") Dissimilarities : 1 2 21 22 45 46 2 11 21 118 107 22 124 113 6 45 143 132 89 87 46 124 113 108 106 19 47 115 104 103 101 28 9 Metric : manhattan Number of objects : 7 > ## this one (k=3) gave problems, from ss = 6 on ___ still after 2002-12-28 ___ : > for(ss in 4:nrow(ru4)){ + cat("---\n\nsample size = ",ss,"\n") + print(clara(ru4,k=3,met="manhattan",sampsize=ss)[clInS]) + } --- sample size = 4 $objective [1] 7.714286 $i.med [1] 1 4 7 $medoids x y 1 4 53 22 32 149 47 78 94 $clusinfo size max_diss av_diss isolation [1,] 2 11 5.50000 0.09565217 [2,] 2 6 3.00000 0.05940594 [3,] 3 28 12.33333 0.27722772 $sample [1] "1" "22" "45" "47" --- sample size = 5 $objective [1] 7.714286 $i.med [1] 2 3 7 $medoids x y 2 5 63 21 28 147 47 78 94 $clusinfo size max_diss av_diss isolation [1,] 2 11 5.50000 0.10576923 [2,] 2 6 3.00000 0.05825243 [3,] 3 28 12.33333 0.27184466 $sample [1] "2" "21" "22" "45" "47" --- sample size = 6 $objective [1] 6.428571 $i.med [1] 2 4 6 $medoids x y 2 5 63 22 32 149 46 85 96 $clusinfo size max_diss av_diss isolation [1,] 2 11 5.500000 0.09734513 [2,] 2 6 3.000000 0.05660377 [3,] 3 19 9.333333 0.17924528 $sample [1] "2" "21" "22" "45" "46" "47" --- sample size = 7 $objective [1] 6.428571 $i.med [1] 2 4 6 $medoids x y 2 5 63 22 32 149 46 85 96 $clusinfo size max_diss av_diss isolation [1,] 2 11 5.500000 0.09734513 [2,] 2 6 3.000000 0.05660377 [3,] 3 19 9.333333 0.17924528 $sample [1] "1" "2" "21" "22" "45" "46" "47" > for(ss in 5:nrow(ru3)){ + cat("---\n\nsample size = ",ss,"\n") + print(clara(ru3,k=4,met="manhattan",sampsize=ss)[clInS]) + } --- sample size = 5 $objective [1] 13.625 $i.med [1] 4 5 10 15 $medoids x y 4 9 77 21 28 147 45 85 115 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 29 16.50 0.3258427 [2,] 5 14 9.00 0.1573034 [3,] 4 30 19.25 0.3370787 [4,] 3 15 10.00 0.1351351 $sample [1] "3" "4" "21" "45" "62" --- sample size = 6 $objective [1] 9.0625 $i.med [1] 3 7 13 15 $medoids x y 3 10 59 23 35 153 48 74 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 19 10.00 0.1881188 [2,] 5 13 5.60 0.1354167 [3,] 4 30 11.75 0.3448276 [4,] 3 15 10.00 0.1724138 $sample [1] "3" "21" "23" "45" "48" "62" --- sample size = 7 $objective [1] 9.0625 $i.med [1] 3 7 13 15 $medoids x y 3 10 59 23 35 153 48 74 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 19 10.00 0.1881188 [2,] 5 13 5.60 0.1354167 [3,] 4 30 11.75 0.3448276 [4,] 3 15 10.00 0.1724138 $sample [1] "2" "3" "21" "23" "45" "48" "62" --- sample size = 8 $objective [1] 8.8125 $i.med [1] 3 7 12 15 $medoids x y 3 10 59 23 35 153 47 78 94 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 19 10.00 0.1844660 [2,] 5 13 5.60 0.1274510 [3,] 4 28 10.75 0.3373494 [4,] 3 15 10.00 0.1807229 $sample [1] "3" "21" "23" "46" "47" "48" "61" "62" --- sample size = 9 $objective [1] 9.3125 $i.med [1] 2 6 11 16 $medoids x y 2 5 63 22 32 149 46 85 96 63 83 21 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1592920 [2,] 5 8 5.40 0.0754717 [3,] 4 19 9.75 0.2467532 [4,] 3 30 15.00 0.3896104 $sample [1] "2" "21" "22" "23" "45" "46" "47" "61" "63" --- sample size = 10 $objective [1] 8.5625 $i.med [1] 3 7 11 15 $medoids x y 3 10 59 23 35 153 46 85 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 19 10.00 0.1696429 [2,] 5 13 5.60 0.1214953 [3,] 4 19 9.75 0.2065217 [4,] 3 15 10.00 0.1630435 $sample [1] "2" "3" "22" "23" "45" "46" "47" "61" "62" "63" --- sample size = 11 $objective [1] 8.6875 $i.med [1] 2 7 12 15 $medoids x y 2 5 63 23 35 153 47 78 94 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1730769 [2,] 5 13 5.60 0.1274510 [3,] 4 28 10.75 0.3373494 [4,] 3 15 10.00 0.1807229 $sample [1] "1" "2" "3" "4" "23" "24" "25" "45" "47" "48" "62" --- sample size = 12 $objective [1] 8.8125 $i.med [1] 3 7 12 15 $medoids x y 3 10 59 23 35 153 47 78 94 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 19 10.00 0.1844660 [2,] 5 13 5.60 0.1274510 [3,] 4 28 10.75 0.3373494 [4,] 3 15 10.00 0.1807229 $sample [1] "2" "3" "22" "23" "24" "25" "46" "47" "48" "61" "62" "63" --- sample size = 13 $objective [1] 8.4375 $i.med [1] 2 7 11 15 $medoids x y 2 5 63 23 35 153 46 85 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1592920 [2,] 5 13 5.60 0.1214953 [3,] 4 19 9.75 0.2065217 [4,] 3 15 10.00 0.1630435 $sample [1] "1" "2" "4" "22" "23" "24" "25" "45" "46" "47" "61" "62" "63" --- sample size = 14 $objective [1] 8.4375 $i.med [1] 2 7 11 15 $medoids x y 2 5 63 23 35 153 46 85 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1592920 [2,] 5 13 5.60 0.1214953 [3,] 4 19 9.75 0.2065217 [4,] 3 15 10.00 0.1630435 $sample [1] "2" "3" "4" "22" "23" "24" "25" "45" "46" "47" "48" "61" "62" "63" --- sample size = 15 $objective [1] 8.375 $i.med [1] 2 6 11 15 $medoids x y 2 5 63 22 32 149 46 85 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1592920 [2,] 5 8 5.40 0.0754717 [3,] 4 19 9.75 0.2065217 [4,] 3 15 10.00 0.1630435 $sample [1] "2" "3" "4" "21" "22" "23" "24" "25" "45" "46" "47" "48" "61" "62" "63" --- sample size = 16 $objective [1] 8.375 $i.med [1] 2 6 11 15 $medoids x y 2 5 63 22 32 149 46 85 96 62 77 12 $clusinfo size max_diss av_diss isolation [1,] 4 18 9.50 0.1592920 [2,] 5 8 5.40 0.0754717 [3,] 4 19 9.75 0.2065217 [4,] 3 15 10.00 0.1630435 $sample [1] "1" "2" "3" "4" "21" "22" "23" "24" "25" "45" "46" "47" "48" "61" "62" [16] "63" > > ## Last Line: > cat('Time elapsed: ', proc.time() - .proctime00,'\n') Time elapsed: 1.79 0.01 1.8 NA NA > ## Lynne (P IV, 1.6 GHz): 18.81; then (no NA; R 1.9.0-alpha): 15.07 > ## nb-mm (P III,700 MHz): 27.97 > > proc.time() user system elapsed 1.89 0.07 1.95