Import Data dan Library

Sumber : https://www.kaggle.com/datasets/arjunbhasin2013/ccdata

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.2
## Warning: package 'ggplot2' was built under R version 4.4.3
## Warning: package 'tidyr' was built under R version 4.4.2
## Warning: package 'readr' was built under R version 4.4.2
## Warning: package 'purrr' was built under R version 4.4.2
## Warning: package 'stringr' was built under R version 4.4.3
## Warning: package 'forcats' was built under R version 4.4.2
## Warning: package 'lubridate' was built under R version 4.4.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)
library(caret)
## Warning: package 'caret' was built under R version 4.4.3
## Loading required package: lattice
## 
## Attaching package: 'caret'
## 
## The following object is masked from 'package:purrr':
## 
##     lift
library(factoextra)
## Warning: package 'factoextra' was built under R version 4.4.3
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(dplyr)
library(tidyr)
library(scales)
## 
## Attaching package: 'scales'
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
library(RColorBrewer)
dataship <- read.csv("C:/Users/Resea/Documents/Semester 5/TPG/Analisis Gerombol/Ship_Performance_Dataset.csv")
dataship <- dataship[1:500, 6:9]
dataship
##     Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm Draft_meters
## 1                  12.59756       2062.9840           1030.94362    14.132284
## 2                  10.38758       1796.0574           1060.48638    14.653083
## 3                  20.74975       1648.5567            658.87414     7.199261
## 4                  21.05510        915.2618           1126.82252    11.789063
## 5                  13.74278       1089.7218           1445.28116     9.727833
## 6                  18.61620       2171.6466            723.30421    14.916320
## 7                  20.43312       2505.0435            270.11859     8.455264
## 8                  23.49805        814.8065           1717.32841     9.283780
## 9                  17.30936       1179.0188            429.56431     6.002358
## 10                 23.22710       2685.4017           1588.79228    11.721261
## 11                 11.63511       2522.6972           1224.84627    10.900540
## 12                 18.25358       2129.5179           1311.97858    11.955648
## 13                 10.22534       1599.1261           1499.72361    11.136576
## 14                 12.50124       2780.4496           1474.07188     7.620740
## 15                 11.71878       1994.0251           1320.45784    12.145870
## 16                 15.08722        578.8929           1932.21313    12.998270
## 17                 20.73784       2525.6729           1813.94557    10.943832
## 18                 14.67204       1930.3790            884.79010     5.294925
## 19                 23.76429       1771.7695           1061.93297     8.521647
## 20                 22.63880       1504.1159           1146.91562    12.558873
## 21                 23.80385       1120.6992           1169.47850    10.544799
## 22                 22.76036       2335.2629           1461.91754     7.980762
## 23                 18.75487       1305.4237            354.59967     8.052450
## 24                 15.22835       1283.1425            713.20555    10.911586
## 25                 18.06901       2922.2826            559.86135    10.417704
## 26                 17.67156       1845.7647           1708.79535    10.508273
## 27                 20.99496       2296.3298            275.18711     7.124895
## 28                 14.06855       2658.6562           1799.79640    12.081070
## 29                 18.00365       1643.9365            177.16643     9.288473
## 30                 11.02444       2957.6141            801.86435    13.644204
## 31                 15.96204        540.9402           1376.42028    14.675854
## 32                 21.42788       2027.8854           1694.34412    11.765945
## 33                 18.05569       2940.9806           1674.05609    14.255468
## 34                 14.48895       1541.6160           1602.75540    10.249176
## 35                 23.29097        520.0793           1532.27522    11.462349
## 36                 10.19866        504.4811            378.28538    12.145465
## 37                 23.03682       1228.1039            150.19837     7.434287
## 38                 13.04007       2012.8877           1057.33372    13.378386
## 39                 18.26541       1223.1646           1592.74283     6.831529
## 40                 24.27464       2041.3466           1487.37172     5.571069
## 41                 22.89761       2450.5793           1229.56610     6.420262
## 42                 19.41907        709.2840            524.84958     7.788783
## 43                 19.08942       1095.2398           1801.17494    14.086731
## 44                 21.61731       2065.6516           1940.01072     9.754800
## 45                 16.01010       2523.3902            491.25992    13.890456
## 46                 22.36635       2814.3636            961.82041     5.728426
## 47                 12.79452        655.5854            993.38838     5.985634
## 48                 19.83684       1630.2344            343.49013    14.921601
## 49                 22.63437       2212.7052            732.29402     6.111994
## 50                 12.28505       1398.2084            317.98342     5.450862
## 51                 22.80571       1238.7209           1635.06560     5.789772
## 52                 24.14346        543.3802           1311.11802     5.315510
## 53                 20.30487       1763.0069           1794.33912     7.291651
## 54                 13.62202       1796.7442            948.24020     6.335936
## 55                 14.86132        709.3117           1598.03697     6.734772
## 56                 23.09077        907.9932            329.76634     5.830493
## 57                 16.88110       2386.4725            281.73023    13.559434
## 58                 22.97615       2607.6572            185.58222    14.424414
## 59                 12.62777       2310.3487            714.52841    14.771734
## 60                 16.20612       1694.9922           1126.39547     6.091262
## 61                 21.72076       1087.7231           1504.26123     9.384915
## 62                 22.23475       1410.1987           1163.57630     9.555535
## 63                 14.23324       2871.3403           1864.20068     9.864785
## 64                 13.03322       1880.7677           1782.56048    11.971983
## 65                 13.62630       2171.9131           1884.78458     8.037293
## 66                 24.11178       2085.0796           1534.45979    14.296864
## 67                 18.79723       2522.0872           1396.16698     9.850449
## 68                 10.33086        762.0545            738.34712    11.900300
## 69                 15.53457       2489.8838           1553.63649     8.770965
## 70                 15.19006       1765.8056            603.39694     5.120040
## 71                 24.60838       1528.2264            248.13984    14.645511
## 72                 15.37892       1144.1660           1648.53065     6.649504
## 73                 10.86055        678.1802           1367.99208     9.040671
## 74                 15.81596       1131.9954           1588.17928    14.723086
## 75                 22.94994       2568.9986            582.16663    13.400490
## 76                 24.07484       2397.8916            941.27195    11.679049
## 77                 21.94581        759.2487            763.15677     6.387618
## 78                 21.45526       2290.7194            489.57086     8.974810
## 79                 18.42257       1904.8953            554.36956     9.785255
## 80                 20.56654       2351.5551            113.85873    13.064045
## 81                 22.52226       1285.5119           1617.06039     6.496371
## 82                 23.66038       2539.6503           1989.84575     7.177801
## 83                 24.75791       2798.1599           1677.16931    13.943580
## 84                 21.16316       2204.8809           1283.73559    11.913643
## 85                 22.35513       2126.2191           1496.56761     5.932365
## 86                 10.92496       2073.6947            803.89325     6.499953
## 87                 12.06805       1625.0007            203.50451     9.533687
## 88                 12.83738       2212.3856           1045.77787    13.258846
## 89                 21.54155       1097.8258            507.09246     5.356473
## 90                 22.39074       1360.1954           1889.55668     6.713454
## 91                 18.75395        534.7910           1809.76993     5.063586
## 92                 22.53122        994.0679           1324.91849    14.294956
## 93                 23.23114        990.9944            872.29015    13.170737
## 94                 23.16255       1031.0331             87.19641     9.420665
## 95                 19.37909       2371.6461            790.34010    14.350742
## 96                 22.75165        884.8436            203.55300    11.187078
## 97                 22.73431       2261.8987           1096.49090     7.143937
## 98                 17.94855       1681.5346            350.46830    11.815473
## 99                 24.38103       1309.6090            842.60113    10.637096
## 100                22.05902       2029.9786           1088.04479    11.561657
## 101                19.01606       1085.7584            294.63756    14.614545
## 102                18.08165        585.1951             72.61348    10.732201
## 103                20.70788       2647.5406            190.36586     6.367843
## 104                11.28591        847.7019           1795.99796     6.776043
## 105                22.72033        869.2678            210.74791     9.462868
## 106                13.85571       1290.3930           1531.71903     8.563355
## 107                22.02165       1682.8123            658.64762     5.125582
## 108                15.08537       2184.9140           1867.47283    11.506457
## 109                22.66313       1657.7807           1029.72957    12.129401
## 110                20.11810       2650.9363           1376.30574    12.329766
## 111                11.21137       1892.0776            173.85468    11.720547
## 112                21.61077       1184.2806            372.27738    14.179822
## 113                11.36411       2499.9373           1133.16428    10.178758
## 114                17.23082        829.6164            824.76913     8.375318
## 115                17.56600       2813.3228           1923.78017    12.323734
## 116                23.60755       1537.1550            307.06781     7.038043
## 117                21.03046       1934.0625           1033.81492     6.774869
## 118                14.43417       1432.6218            143.18551    14.906479
## 119                19.25728        940.2119           1288.51529    10.212289
## 120                23.85716       1779.5723           1744.34571    13.910377
## 121                13.76247       2693.6342             76.81854    13.154255
## 122                19.29693        818.2716           1781.64835    12.723021
## 123                19.87479        892.0090           1364.92789    12.090510
## 124                17.45314       2521.8167           1955.86233    10.367868
## 125                17.30228       1471.8151            143.36083    14.456739
## 126                22.85310        893.4271           1822.02011     5.157223
## 127                10.13615       1413.9877            492.33489    13.164127
## 128                18.06087       2894.6493            819.54242     5.073916
## 129                22.70870       1512.1199            771.34059     9.854360
## 130                12.35433       2281.8721            701.39206    14.454351
## 131                15.93637       1622.4763           1471.94399    11.548265
## 132                24.11754        866.9226            599.29538     7.032850
## 133                16.89182        609.4533           1653.69701    10.591492
## 134                23.02676       2624.9315           1607.74856    11.709188
## 135                14.64564       2605.7648           1714.86801    11.434511
## 136                14.65417       1313.7168           1000.23274    10.707528
## 137                22.55050        638.2856            444.90771    11.292760
## 138                11.52589       1895.9180           1391.93661    10.306034
## 139                10.56409       2328.2279             68.08607     7.556609
## 140                21.27536       2990.7950            201.24938    14.910589
## 141                11.28004       1554.2889            170.93011    12.574490
## 142                11.50912        712.0045           1417.08103     6.450089
## 143                16.06011        580.8206            817.44203     7.715641
## 144                11.82553       1131.3126            601.84733    13.561475
## 145                24.87095        666.6610            268.37372     5.627579
## 146                22.16899       2338.6079           1024.43027    12.516954
## 147                10.05167       2403.9187            779.07341    10.117509
## 148                18.01376       2072.9331            965.63810    12.592137
## 149                17.87312        782.8303            431.47821     9.636206
## 150                11.75901       1400.6178            630.72542     7.729929
## 151                18.73786       1139.8074            409.55646     8.628002
## 152                24.31780       1895.1698           1466.59770    11.046365
## 153                18.19935       1777.7972            634.69903    14.966545
## 154                22.03319       1775.9926            427.88466     7.820235
## 155                21.63615       2645.4427            747.01552    10.962876
## 156                12.41344       1629.2877            162.84889    13.226933
## 157                14.51956        727.4354           1531.94300    11.859090
## 158                20.51474       1240.0738           1463.46202     5.698510
## 159                11.14641        663.0705           1674.72228     6.291202
## 160                19.63677       1726.3137            597.46952    11.388067
## 161                22.39553       2850.9903           1327.00600    10.302152
## 162                20.66860        768.7005           1970.77069    13.499041
## 163                18.78012        815.6819            599.01096     5.237161
## 164                13.06222        998.2116            977.77829    14.684212
## 165                24.66249       2330.0596           1453.18759    11.690578
## 166                16.37537       2638.2389            710.58144     8.245658
## 167                18.34635       1220.9464            570.24032     7.900719
## 168                17.48104       2158.4206            474.81489     7.167293
## 169                18.88184        911.1700            406.89787     9.256225
## 170                15.07896       1751.1251           1566.28928    10.094847
## 171                20.26043       1736.8883           1905.15339    12.370077
## 172                13.56689        842.4208           1478.09756    12.600473
## 173                12.07762       2120.1754            694.43932     9.976304
## 174                22.24648        680.8540            696.91420     8.827087
## 175                22.62739       2422.0680           1135.26821    11.400924
## 176                20.58443        860.2095           1577.80435     7.782659
## 177                14.38716       2809.6190            461.23370    10.191207
## 178                20.49400       2876.7584            358.93452    12.937578
## 179                17.81392       2993.2265            351.97585    10.272933
## 180                20.91340       1045.6998            248.67442     9.101045
## 181                17.39708       1271.0948            579.97523    12.565405
## 182                14.76112       2962.4354           1475.65044    14.825901
## 183                20.55081       1467.0109           1054.77458     7.624080
## 184                17.84055       1441.3594            991.03464    11.298249
## 185                14.15602       2058.2113           1102.15834    14.020608
## 186                13.93965       2928.9597           1494.31538     8.277471
## 187                16.74015       2396.6385            891.74842     5.365741
## 188                11.96620       2371.0740            551.52412     6.750113
## 189                24.16161       1088.3051            688.47461     5.595817
## 190                10.68182       2489.6068            902.36614    12.700776
## 191                13.20963       1528.4347            123.11414    12.659648
## 192                21.19953       1464.1173            804.68353    11.875788
## 193                22.43233       2531.1060            561.69343    10.652707
## 194                10.40343       2081.8593           1711.64293    13.320022
## 195                23.82119        730.4000           1760.57059    13.889950
## 196                23.94911       2915.4408            758.11073    13.559499
## 197                11.12406       1493.9086           1279.96895    11.590024
## 198                10.69954        928.5280           1899.87729     5.281448
## 199                12.25630        568.2896            495.49770    11.859816
## 200                24.41803       1510.5443            968.54221     5.416479
## 201                14.74407       1846.0898           1586.11052     5.800639
## 202                10.18917       2585.8496            692.06312     7.925640
## 203                24.47517       2253.4898            568.50285    12.313777
## 204                18.69641        542.9951             89.98700    14.949668
## 205                11.47550       1889.1038           1085.56966    11.449172
## 206                15.43850        654.1636           1143.69280     7.699517
## 207                13.01345       2613.1451           1705.87070     7.659909
## 208                23.74410       1925.0861            124.81231    12.197450
## 209                24.99704       1644.3030           1576.45114    14.704515
## 210                15.48029        886.4264            272.29130     8.613753
## 211                13.95550       2143.3057            558.32856     6.309419
## 212                10.60690       1481.4108           1902.15448     9.201779
## 213                15.12508       2947.9475            555.28244     7.418694
## 214                19.83196       1300.4309             91.43988    13.398558
## 215                22.20826       1971.8521            654.26091     6.686104
## 216                19.69080       2592.1127           1794.53297     5.898323
## 217                18.69271       1143.1765            255.20026     9.279358
## 218                16.05152       1181.8845           1790.84440     5.537588
## 219                10.36508       1195.3456            247.05651    12.560964
## 220                23.39345       2356.6645           1788.57365     7.548321
## 221                13.98517       1814.5751           1830.54096     5.066375
## 222                22.37753       1498.2242            448.89575     7.576489
## 223                13.87824       1576.4300           1682.68380     7.067593
## 224                14.22455       2771.7336           1814.09031     7.231079
## 225                19.16115       2362.8886           1706.67667     8.354080
## 226                20.58447       2416.6637            484.69393    10.950854
## 227                20.36535       2390.4295            427.82286     6.172464
## 228                12.19867       1905.9235            398.45113     6.702690
## 229                17.05728        965.5039            799.43980     8.801820
## 230                17.56723        541.0039            861.29050     6.821483
## 231                19.70461        659.1855           1330.15778    11.224658
## 232                15.76097       1201.4830            856.54641     5.738156
## 233                15.23155       2852.7968            591.97238    12.770144
## 234                21.07038        993.2413           1282.97113    12.956110
## 235                14.81196       2456.0574           1216.57966    14.983936
## 236                16.81515        777.4765            538.30515    12.703134
## 237                17.07090        942.9747            913.11148    14.485655
## 238                16.79687       1579.7496            539.79202    13.779696
## 239                11.37471       1626.3646            691.12398     7.286178
## 240                17.45325        683.9206           1671.78654     9.082201
## 241                24.19857       2518.2603           1933.31219     5.723345
## 242                19.69463       1247.8495           1520.46665     7.256666
## 243                17.51046       1993.1633            947.43614    11.788187
## 244                14.78317       1514.2993            674.90607    11.365947
## 245                10.21984       1498.6574            885.94919     7.265604
## 246                24.72513       1846.7498            372.11934     7.078740
## 247                13.59747       1399.4045           1763.21662    14.264679
## 248                13.78183        596.6413           1917.90036    11.356678
## 249                13.67086       2945.4649            399.16296     7.928567
## 250                11.30168       2394.1770           1691.74741    11.718317
## 251                21.12691       2501.2889            480.86677     5.975342
## 252                12.96759       2150.5034           1891.63610     8.444983
## 253                20.15349        982.3062           1587.28870    12.951893
## 254                10.98623        914.8781            810.65382     5.907498
## 255                10.37825       2554.9075           1608.32446     9.140081
## 256                17.24386       1952.6281           1792.69093     5.942868
## 257                20.25066       1675.6762           1396.55904     8.661889
## 258                21.74340       1705.8739           1288.79092    14.107809
## 259                10.68415       1035.6881           1728.31782     6.971895
## 260                24.77926       2147.8650           1795.79808     5.281270
## 261                15.50346       2077.4356           1200.53708    14.370975
## 262                18.94946       2108.8000           1094.47814    12.864760
## 263                16.19108       2459.2758            262.57618    13.326276
## 264                21.02504       1257.2892            694.52843    11.609566
## 265                13.93863       2488.5673            422.63992    10.937113
## 266                12.07026       1634.6894            492.87142     5.382325
## 267                11.19883       1059.7294            675.54172     8.087615
## 268                13.74401       1073.4706            662.24832     7.789510
## 269                24.29276       2272.7000           1709.52240     8.527637
## 270                23.75283       1371.0885            292.98108    10.178696
## 271                10.47458       2191.3594            607.92481     7.267483
## 272                16.85060       1395.3627           1263.67390    14.554244
## 273                10.21642        938.1992            459.04181    12.756660
## 274                20.34045       2042.4747            459.10350    12.164557
## 275                22.48191        789.4537            664.83269     7.513533
## 276                18.69034       2073.8102           1366.96217     7.148470
## 277                11.53760        688.6105           1899.96187    10.488899
## 278                10.89135       1084.4696            506.31064    11.954054
## 279                20.92356        695.0024            307.19588     9.870327
## 280                19.28948        811.6861            649.80752    10.312133
## 281                16.78573       2952.9545           1279.18256     6.731708
## 282                21.62287       1504.3347           1446.94296    11.407849
## 283                17.96829       2345.1970           1308.66229    10.452187
## 284                12.49472       2503.9141           1879.33911    11.451643
## 285                13.45747       2525.3298            496.67393    14.024181
## 286                12.09319       2122.3334           1415.60517    14.209162
## 287                20.20112        732.9764            592.19361    13.677871
## 288                24.48669        924.0985           1723.93937    11.721611
## 289                13.55199        982.9855            703.77913    13.619149
## 290                16.69825       2303.2087            129.21452     9.382540
## 291                15.48651        875.1495            817.64217    13.051408
## 292                13.19546       2694.8446            870.35354     9.177140
## 293                15.29386        900.7127            269.88963    11.638994
## 294                12.95549       2335.4603           1739.20673     7.486446
## 295                15.02204       2183.8012           1429.61218     7.854958
## 296                10.15075       2044.5469           1606.80184    14.335679
## 297                17.07069       1304.6907           1528.37832    13.739565
## 298                21.10019       2606.7176           1106.70310     5.154981
## 299                24.26534       1343.8706            969.82082     5.226115
## 300                15.54197       2687.4207           1979.17849     9.997487
## 301                18.62798       1282.7182           1084.00394     5.478139
## 302                24.91018       2357.8178            164.76103    10.133511
## 303                11.27010       2188.0041            498.78583     8.603338
## 304                10.11937       1214.1633           1646.33331    12.301405
## 305                20.07304       1662.1247            438.96550     6.223896
## 306                24.86511       1239.9107           1545.68080    10.157419
## 307                22.50830       1856.7310            491.85561     7.372930
## 308                11.81257       2278.6126            713.90581     8.043870
## 309                14.80961        566.8926           1733.72893    13.144292
## 310                23.60748       2039.0007            559.63574     8.344844
## 311                23.92748       2392.2610           1504.69077    13.012022
## 312                12.15287       2764.8954            878.80993     5.179758
## 313                17.40898       2825.2216           1041.73414    13.799273
## 314                12.72063       2410.4822           1790.77937     8.233912
## 315                16.30208       2268.0562           1879.14528     5.952393
## 316                23.78714       1252.3859             79.95411    13.014097
## 317                16.36894        699.8535            837.79209     7.192182
## 318                18.29807       2334.3637            449.36677     8.030344
## 319                14.33096        990.7571            300.15452    10.389873
## 320                17.60270       1682.3814            679.71560     5.017875
## 321                14.37938       1197.6769            326.07014    14.636441
## 322                20.53148       2318.9712           1354.25034    13.200091
## 323                16.38558       2427.3243            748.23893    10.810900
## 324                14.32620        674.1713           1772.04209     6.786579
## 325                18.89742       1848.2761           1226.13715     6.596924
## 326                24.98046       2983.2368           1805.67168     8.686142
## 327                21.85748       1946.8077           1090.76237    10.659062
## 328                14.29104       1863.7275           1980.63497    14.253202
## 329                10.86065       1421.5042           1975.64753    10.975940
## 330                19.66445       1751.8946           1760.47418    14.002834
## 331                15.39904        866.0199           1560.20542     8.335197
## 332                18.29273       1122.7665           1817.78287    12.550190
## 333                22.30826       2371.5328           1487.76349     5.269242
## 334                19.83611       1805.1895           1289.79146    10.488185
## 335                24.05516       1746.6291           1695.86810     5.314281
## 336                21.75192       1505.5523           1060.56120     7.319652
## 337                16.10623        800.3541           1535.81801     8.418789
## 338                14.77774       1133.8053            907.37894    10.074222
## 339                17.58910       1475.0232            301.85946     7.562543
## 340                11.09147        836.9753            443.20421    10.359196
## 341                12.48359       2451.0503            628.20700     9.841371
## 342                21.62989        878.3880           1447.95499     7.649765
## 343                24.47958        864.8487           1874.12366     7.690806
## 344                22.04455        599.6047            540.70829    13.405805
## 345                18.18857       1376.1421            989.60150    10.625667
## 346                19.10073       2035.6427            785.18650     9.187279
## 347                13.62567       1170.2513           1189.11654    12.000004
## 348                22.29813       1644.2857           1880.66152     6.670571
## 349                23.43620       2516.1729             68.82644     7.771379
## 350                22.83736       1940.3339            313.26390     9.393485
## 351                15.83526        867.5134           1622.08750     7.193346
## 352                15.16854       2777.1350           1340.46743     5.648314
## 353                17.21046        725.1323           1786.32106     6.760727
## 354                24.60594       1117.7911            641.19311    12.945723
## 355                17.22714       1068.7075             87.76439     8.985557
## 356                18.02975        599.3705            586.68752     9.813566
## 357                16.90270       1659.9764            396.25800    14.466860
## 358                15.94673       2803.7347           1710.66751     8.554325
## 359                16.07347       2483.3363            363.50183    10.349216
## 360                20.92901       1569.6016            740.43434     9.592651
## 361                10.77142       1372.1658            214.68942    13.066990
## 362                10.88392        773.3206            348.67994     7.148942
## 363                18.56602       1517.0135           1852.62895     6.763938
## 364                14.38931       2394.6880           1714.85451     9.332139
## 365                14.44364       1065.8398            101.92520     9.002369
## 366                19.43890       1528.3875            840.40157    11.057214
## 367                24.59505       1001.2240            550.92821    14.423150
## 368                24.33228       1151.0910            874.82904     5.771854
## 369                17.39244       1329.7975            961.12312     5.210404
## 370                14.26124       2143.2141           1335.98326    12.500726
## 371                13.27338        711.8135            371.35494     8.038047
## 372                13.14713       1631.7841           1363.31288    12.208808
## 373                10.63952       2290.9487           1127.54607     7.798359
## 374                10.51714       1297.5769            510.80050    12.882525
## 375                22.85721       1992.5590            465.01218    13.565908
## 376                11.33976       2382.2897            698.01430     9.397910
## 377                11.72158       1584.5406           1181.81888     8.355455
## 378                17.82181       1287.3812           1040.99248     6.670863
## 379                15.88049       1597.5024           1664.25004     6.034248
## 380                14.91295       2150.5805           1282.37717     8.467009
## 381                15.36562       1269.5762           1271.10150    10.397680
## 382                19.29671       2807.7068             94.66449     9.453793
## 383                16.63115        520.8292           1786.85678     8.150682
## 384                24.91462       2489.7662            530.14095     7.512101
## 385                12.57357       1795.8166           1726.01713    12.459288
## 386                24.23783       2359.7612           1249.67613    13.015400
## 387                18.11934       1429.0771            477.20374     6.921955
## 388                23.45058       1267.7026            120.03689     6.918317
## 389                13.82486       1071.6219            102.27719    12.056533
## 390                14.93556        905.1408           1416.34188    10.938678
## 391                13.54432       2295.7322           1686.54383    14.701341
## 392                21.90359       1329.5868            600.16795     5.272282
## 393                15.41297       1096.0759           1839.71562     8.389246
## 394                10.53841        721.1233            103.51220     5.110126
## 395                19.43631       2971.8961           1458.65627    14.333634
## 396                21.54807       1719.9553            340.01025     5.046245
## 397                12.62286       1034.8714           1388.66520    10.959822
## 398                14.76304       2706.1120           1833.23429     8.453122
## 399                21.33223        717.1855            697.49255    12.962534
## 400                19.91154       2726.2979           1626.31454    13.481559
## 401                13.91393       2722.3980           1631.42853     9.669865
## 402                24.36955       2559.5429            577.93958     9.412266
## 403                22.48708       1537.1612           1825.73825     6.495941
## 404                15.19615       2714.7809           1319.96275     7.565454
## 405                23.34410       2102.7271           1382.77146     8.821511
## 406                20.75947       1973.6418            329.88882    11.053048
## 407                19.23999       1099.2550           1315.05619     8.870302
## 408                11.37433       1678.8396            188.23395    13.282741
## 409                23.08676       1446.4882             88.07393    14.410304
## 410                10.68141        810.6404           1057.29341    13.568590
## 411                12.60039       1387.7423            461.36883    11.639389
## 412                20.11692       2325.6121           1090.50249    14.606360
## 413                23.95394       1415.6751             52.28661     5.837265
## 414                17.85581        554.8260            520.49980     8.434534
## 415                20.14696       2122.1020           1082.78977    13.216944
## 416                18.74248       2754.7981            169.77995     6.952519
## 417                21.67848       2948.7279            538.89519    10.072658
## 418                16.44646       2463.5463            279.65153     8.677564
## 419                22.17694        965.4655           1194.62023     8.806841
## 420                12.80061       2995.5496           1285.78290     8.638543
## 421                13.59054       1317.5852           1906.34670     7.439784
## 422                19.45618        817.8916            919.88829     5.722567
## 423                14.37013       2086.3589            612.20586     5.480212
## 424                13.38918       1591.8048            204.94327     6.517172
## 425                13.57737       2047.9701            968.15564     8.697701
## 426                14.24837       2247.8866            234.23564     7.583368
## 427                17.57109       1798.8604            425.67139    12.563189
## 428                22.15218       2892.1814           1153.91073     5.707939
## 429                14.46030        834.1108            986.11220    14.924104
## 430                19.18988       2109.9656            482.18406    10.079461
## 431                24.50526       2494.4207           1882.56799    13.516766
## 432                14.38292       2125.4026            950.64260    10.203466
## 433                21.91714       1826.4702           1210.98948    12.384915
## 434                21.47639        568.2403            873.42653    14.624869
## 435                20.41151       1058.3499            803.50800     7.710338
## 436                11.50406       2586.3702           1975.73976    10.222109
## 437                11.11041       1020.9152            528.04692    13.599187
## 438                20.66718       2031.2802            610.58887    11.358770
## 439                17.13324       1894.6660           1597.68657    10.697587
## 440                22.45786       2874.9285            742.45079     6.859306
## 441                11.31514       1895.2596            109.52524    13.269937
## 442                17.02642       1831.0654            579.44131    13.764015
## 443                14.99106       2809.9075           1524.71581    10.567446
## 444                16.91619       2334.5899            987.29314    13.833227
## 445                13.76866        761.5061           1298.75507    12.461074
## 446                18.14361       2220.4322            621.47668     7.262309
## 447                17.03789       1482.4727           1389.89198     5.207722
## 448                21.43569       2153.1074           1104.41842     7.639041
## 449                12.68031       2930.7323            738.83932     8.307892
## 450                10.13271       1216.1019           1304.73306    10.053166
## 451                24.70540        937.5713            834.35013    14.724162
## 452                20.73297       1818.6281            242.03162     8.280086
## 453                22.87678       1836.2669            485.22847    10.968748
## 454                23.28563       1052.8380            145.95880     7.106194
## 455                11.14073       1528.4311            732.98569     7.242290
## 456                19.53223       1380.7025           1849.79899    10.830388
## 457                15.92743       1447.8669           1081.28486     6.992985
## 458                11.56165        506.0392           1895.73003     9.749492
## 459                21.24564       2924.2025           1608.55121     7.846189
## 460                22.61881       2061.0894           1321.95698     5.674680
## 461                12.50316       2805.2887           1034.09722    14.700947
## 462                15.88589       2365.4998            613.34524    10.787510
## 463                22.91557       1459.1685           1618.82794    13.155722
## 464                20.27755        901.7697            516.16624     7.338551
## 465                12.23214       1079.9900            737.25230     8.757592
## 466                16.58961       2465.2526           1940.10765    10.214133
## 467                17.86189       1879.0813            876.02426    11.927641
## 468                24.28534       1049.6293            891.99782    13.854832
## 469                21.32383       2745.8281           1957.45476     7.550977
## 470                14.75333       2268.9520           1178.65679     8.050030
## 471                17.41775        890.9653           1170.81313    14.666833
## 472                24.65124       1332.9501            308.33198     5.003111
## 473                17.92653       2244.8414           1846.53549    14.762431
## 474                19.94915        802.4332            493.81791     8.258445
## 475                24.83649        752.4284           1642.88044     9.022207
## 476                11.34886       2210.4414            251.39817     7.357909
## 477                14.26952       2920.9250            987.61811     6.824384
## 478                19.16296       1973.8371            505.81029    11.841614
## 479                15.34255       1862.9811           1554.73444    14.359155
## 480                20.44931       2696.3118            761.69071    12.104412
## 481                15.30153       2858.5454            402.29789     8.678886
## 482                12.97372       1372.2404            179.35919    14.482199
## 483                14.74902       2450.3907           1600.75528    13.902542
## 484                23.44672       2327.9927           1221.08270    14.404531
## 485                14.37662        689.3851            652.82091     6.428849
## 486                19.15116       1801.3142           1120.76283     9.754092
## 487                11.22011       2667.4441           1389.72831    12.794907
## 488                10.94850       1398.1565           1959.06154    14.101428
## 489                17.94453       1529.1442            200.69291     9.278412
## 490                18.61612        892.5283           1377.55695     6.546640
## 491                20.85463       1269.0787           1633.81426    11.938767
## 492                14.42847        576.7580            688.80859    10.240993
## 493                21.31766       1968.3299            743.45203    11.383523
## 494                18.34760       1425.4686             78.84229    11.478714
## 495                11.61937       2761.3404            171.68158     8.438952
## 496                24.94023        904.0825            692.37443     5.807838
## 497                17.96329       1304.0208           1241.83237    14.002911
## 498                16.50674       1876.8143            496.68015     8.256703
## 499                16.48706       1459.6766           1526.45699    13.108488
## 500                15.43963       2074.8044            657.10033     8.140894
summary(dataship)
##  Speed_Over_Ground_knots Engine_Power_kW  Distance_Traveled_nm  Draft_meters   
##  Min.   :10.05           Min.   : 504.5   Min.   :  52.29      Min.   : 5.003  
##  1st Qu.:13.95           1st Qu.:1095.9   1st Qu.: 514.82      1st Qu.: 7.430  
##  Median :17.74           Median :1682.0   Median : 969.18      Median : 9.987  
##  Mean   :17.63           Mean   :1712.8   Mean   :1003.56      Mean   : 9.949  
##  3rd Qu.:21.49           3rd Qu.:2328.1   3rd Qu.:1525.15      3rd Qu.:12.525  
##  Max.   :25.00           Max.   :2995.5   Max.   :1989.85      Max.   :14.984
str(dataship)
## 'data.frame':    500 obs. of  4 variables:
##  $ Speed_Over_Ground_knots: num  12.6 10.4 20.7 21.1 13.7 ...
##  $ Engine_Power_kW        : num  2063 1796 1649 915 1090 ...
##  $ Distance_Traveled_nm   : num  1031 1060 659 1127 1445 ...
##  $ Draft_meters           : num  14.13 14.65 7.2 11.79 9.73 ...

Standarisasi

dataship_scaled <- scale(dataship)
head(dataship_scaled)
##   Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm Draft_meters
## 1              -1.1533124      0.50054294           0.04853001   1.42965004
## 2              -1.6594890      0.11895535           0.10089070   1.60764622
## 3               0.7138775     -0.09190582          -0.61091453  -0.93988621
## 4               0.7838165     -1.14019497           0.21846284   0.62879469
## 5              -0.8910096     -0.89079389           0.78288918  -0.07568265
## 6               0.2252057      0.65588264          -0.49672065   1.69761404

Menentukan Matriks Jarak dengan Euclidean

distance_shipmatrix <- dist(dataship_scaled, method = "euclidean")
head(distance_shipmatrix,10)
##  [1] 0.6604909 3.1443541 2.6673462 2.1931554 1.5144456 3.0336744 3.6936620
##  [8] 3.4085622 2.8940633 1.3485489

Menentukan Jumlah Klaster Optimal

ship_ward <- hclust(distance_shipmatrix, method = "ward.D2")
ship_ward
## 
## Call:
## hclust(d = distance_shipmatrix, method = "ward.D2")
## 
## Cluster method   : ward.D2 
## Distance         : euclidean 
## Number of objects: 500

Dendogram dengan K=3

fviz_dend(ship_ward, k = 3, 
            rect = TRUE, 
            rect_fill = TRUE,
            main = "Dendrogram Metode Ward's")
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## ℹ The deprecated feature was likely used in the factoextra package.
##   Please report the issue at <https://github.com/kassambara/factoextra/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Hasil Klaster

clusters <- cutree(ship_ward, k = 3)
table(clusters)
## clusters
##   1   2   3 
## 113 176 211

Komponen Hasil

names(ship_ward)
## [1] "merge"       "height"      "order"       "labels"      "method"     
## [6] "call"        "dist.method"

Pada fungsi hclust, beberapa komponen penting yang dihasilkan antara lain:

head(ship_ward$merge,10)
##       [,1] [,2]
##  [1,]  -10 -134
##  [2,]  -59 -130
##  [3,] -239 -455
##  [4,]  -29 -489
##  [5,] -331 -337
##  [6,] -348 -403
##  [7,]  -65 -252
##  [8,]  -57 -263
##  [9,] -127 -374
## [10,]  -37 -388
head(ship_ward$height,20)
##  [1] 0.1035575 0.1337469 0.1679356 0.1698926 0.1942484 0.1958658 0.2079944
##  [8] 0.2081150 0.2136431 0.2148049 0.2218037 0.2266441 0.2475158 0.2477706
## [15] 0.2494671 0.2501606 0.2511085 0.2522182 0.2530802 0.2593598
cluster_hclust <- cutree(ship_ward, k = 3)

data_with_clusters <- dataship %>%
  mutate(Cluster = as.factor(cluster_hclust))

cluster_profiles <- data_with_clusters %>%
  group_by(Cluster) %>%
  summarise(across(where(is.numeric), ~mean(.x, na.rm = TRUE)))

print(cluster_profiles)
## # A tibble: 3 × 5
##   Cluster Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm
##   <fct>                     <dbl>           <dbl>                <dbl>
## 1 1                          13.3           2198.                1048.
## 2 2                          19.9           1485.                1045.
## 3 3                          18.1           1643.                 945.
## # ℹ 1 more variable: Draft_meters <dbl>

Evaluasi Klaster

Terdapat beberapa metrik evaluasi klaster yang dapat digunakan untuk menilai kualitas hasil clustering: - Silhouette Score: Nilai berkisar dari -1 hingga 1, di mana nilai yang lebih tinggi menunjukkan klaster yang lebih baik. - Dunn Index: Nilai yang lebih tinggi menunjukkan klaster yang lebih baik. - Calinski-Harabasz Index: Nilai yang lebih tinggi menunjukkan klaster yang lebih baik.

Silhouette Score

library(cluster)
silhouette_values <- silhouette(cluster_hclust, distance_shipmatrix)
avg_silhouette <- mean(silhouette_values[, 3])
cat("Average Silhouette Score:", avg_silhouette, "\n")
## Average Silhouette Score: 0.1459892

Dunn Index

library(clusterCrit)
## Warning: package 'clusterCrit' was built under R version 4.4.3
dunn_index <- intCriteria(as.matrix(dataship_scaled), 
                          as.integer(cluster_hclust), 
                          c("Dunn"))$dunn
cat("Dunn Index:", dunn_index, "\n")
## Dunn Index: 0.09443172

Calinski-Harabasz Index

ch_index <- intCriteria(as.matrix(dataship_scaled),
                        as.integer(cluster_hclust),
                        c("Calinski_Harabasz"))$calinski_harabasz
cat("Calinski-Harabasz Index:", ch_index, "\n")
## Calinski-Harabasz Index: 88.26635

Karakteristik Klaster dengan Analisis Profil

dataship_clustered <- dataship %>%
  mutate(Cluster = as.factor(cluster_hclust))
# Melihat profil rata-rata setiap klaster
cluster_profiles <- dataship_clustered %>%
  group_by(Cluster) %>%
  summarise(across(where(is.numeric), ~mean(.x, na.rm = TRUE)))

print(cluster_profiles)
## # A tibble: 3 × 5
##   Cluster Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm
##   <fct>                     <dbl>           <dbl>                <dbl>
## 1 1                          13.3           2198.                1048.
## 2 2                          19.9           1485.                1045.
## 3 3                          18.1           1643.                 945.
## # ℹ 1 more variable: Draft_meters <dbl>

Visualisasi Klaster

Visualisasi Klaster pada Dua Dimensi dengan PCA

pca_result <- prcomp(dataship_scaled)
pca_data <- data.frame(pca_result$x, Cluster = as.factor(cluster_hclust))
ggplot(pca_data, aes(x = PC1, y = PC2, color = Cluster)) +
  geom_point(size = 2) +
  labs(title = "Visualisasi Cluster menggunakan PCA",
       x = "Principal Component 1",
       y = "Principal Component 2") +
  theme_minimal()

Berdasarkan visualisasi PCA, kita dapat mengamati bahwa klaster-klaster yang terbentuk memiliki pemisahan yang cukup baik tetapi masih ada beberapa tumpang tindih.

Visualisasi dengan Heat Map

library(reshape2)
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(ggplot2)
dataship_num <- dataship_clustered[, sapply(dataship_clustered, is.numeric)]
dataship_num$Cluster <- dataship_clustered$Cluster

dataship_melted <- melt(dataship_num, id.vars = "Cluster")

ggplot(dataship_melted, aes(x = variable, y = as.factor(Cluster), fill = value)) +
  geom_tile() +
  scale_fill_gradient(low = "white", high = "blue") +
  labs(title = "Heatmap Karakteristik Cluster",
       x = "Fitur",
       y = "Cluster") +
  theme_minimal()

Klaster 1 berwarna paling gelap di Speed_Over_Ground_kn dan Engine_Power_kW menunjukkan bahwa kapal cepat dengan tenaga mesin besar. Klaster 2 memiliki warna agak terang di semua fitur menunjukkan kapal dengan kecepatan dan tenaga mesin sedang. Klaster 3 berwarna paling terang (nilai rendah di semua fitur) menunjukkan Kapal lambat, mesin kecil, mungkin kapal kecil atau kapal nelayan tradisional.

K-Means Clustering

Beberapa metode yang umum digunakan untuk menentukan k antara lain: - Elbow Method - Silhouette Method

Elbow Method

fviz_nbclust(dataship_scaled, kmeans, method = "wss") +
  labs(title = "Elbow Method for Optimal k")

#### Silhouette Method

fviz_nbclust(dataship_scaled, kmeans, method = "silhouette") +
  labs(title = "Silhouette Method for Optimal k")

Didapat bahwa jumlah klaster yang optimum adalah k=8.

Hasil K-Means

set.seed(123)  # Untuk reproduktifitas
k <- 8  # Jumlah klaster optimal
kmeans_result <- kmeans(dataship_scaled, centers = k, nstart = 25)
table(kmeans_result$cluster)
## 
##  1  2  3  4  5  6  7  8 
## 50 61 72 53 60 73 76 55
names(kmeans_result)
## [1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
## [6] "betweenss"    "size"         "iter"         "ifault"
kmeans_result$centers
##   Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm Draft_meters
## 1               0.9784240       0.6040468            0.9228097   -0.8848299
## 2               0.8245809      -0.7013530            0.5212000    0.8972485
## 3               0.6402568       0.8131487           -0.6393102    0.7392474
## 4              -0.7359530      -1.0129491            1.0232342   -0.5283593
## 5              -0.7700610       0.8291439           -0.6620850   -0.8288240
## 6              -0.8629419       0.8561343            0.9087239    0.5637013
## 7               0.7120312      -0.7854791           -0.7640210   -0.8492746
## 8              -0.9314467      -0.8150953           -0.9941984    0.6801942
kmeans_result$tot.withinss
## [1] 727.3713
kmeans_result$size
## [1] 50 61 72 53 60 73 76 55
kmeans_result$iter
## [1] 4
kmeans_result$withinss
## [1]  74.52186  92.17357 112.34410  76.00927  80.69313 115.71457  96.93215
## [8]  78.98265
kmeans_result$betweenss
## [1] 1268.629

Evaluasi Klaster K-Means

distance_matrix <- dist(dataship_scaled)

Silhouette Score

silhouette_values_kmeans <- silhouette(kmeans_result$cluster, distance_matrix)
avg_silhouette_kmeans <- mean(silhouette_values_kmeans[, 3])
cat("Average Silhouette Score (K-Means):", avg_silhouette_kmeans, "\n")
## Average Silhouette Score (K-Means): 0.2509852

Dunn Index

dunn_index_kmeans <- intCriteria(
  as.matrix(dataship_scaled),
  as.integer(kmeans_result$cluster),
  c("Dunn")
)$dunn
cat("Dunn Index (K-Means):", dunn_index_kmeans, "\n")
## Dunn Index (K-Means): 0.07520343

Calinski-Harabaz Index

ch_index_kmeans <- intCriteria(
  as.matrix(dataship_scaled),
  as.integer(kmeans_result$cluster),
  c("Calinski_Harabasz")
)$calinski_harabasz
cat("Calinski-Harabasz Index (K-Means):", ch_index_kmeans, "\n")
## Calinski-Harabasz Index (K-Means): 122.5873

Karakteristik Klaster K-Means

data_kmeans_clustered <- dataship %>%
  mutate(Cluster = as.factor(kmeans_result$cluster))
# Melihat profil rata-rata setiap klaster
cluster_profiles_kmeans <- data_kmeans_clustered %>%
  group_by(Cluster) %>%
  summarise(across(where(is.numeric), ~ mean(.x, na.rm = TRUE)))
print(cluster_profiles_kmeans)
## # A tibble: 8 × 5
##   Cluster Speed_Over_Ground_knots Engine_Power_kW Distance_Traveled_nm
##   <fct>                     <dbl>           <dbl>                <dbl>
## 1 1                          21.9           2135.                1524.
## 2 2                          21.2           1222.                1298.
## 3 3                          20.4           2282.                 643.
## 4 4                          14.4           1004.                1581.
## 5 5                          14.3           2293.                 630.
## 6 6                          13.9           2312.                1516.
## 7 7                          20.7           1163.                 572.
## 8 8                          13.6           1143.                 443.
## # ℹ 1 more variable: Draft_meters <dbl>

Visualisasi Klaster K-Means

Visualisasi Klaster pada Dua Dimensi dengan PCA

fviz_cluster(kmeans_result, data = dataship_scaled,
             geom = "point",
             ellipse.type = "convex",
             palette = "jco",
             ggtheme = theme_minimal(),
             main = "Visualisasi Cluster K-Means")

Terlihat bahwa masing-masing klaster memiliki area yang relatif terpisah, meskipun terdapat beberapa tumpang tindih di batas antar klaster. Hal ini menunjukkan bahwa algoritma K-Means berhasil mengelompokkan data berdasarkan kesamaan karakteristik utama, namun beberapa klaster memiliki karakteristik yang cukup mirip satu sama lain.

Visualisasi dengan Heat Map

library(reshape2)
library(ggplot2)
data_num_kmeans <- data_kmeans_clustered[, sapply(data_kmeans_clustered, is.numeric)]
data_num_kmeans$Cluster <- data_kmeans_clustered$Cluster

data_melted_kmeans <- melt(data_num_kmeans, id.vars = "Cluster")

ggplot(data_melted_kmeans, aes(x = variable, y = as.factor(Cluster), fill = value)) +
  geom_tile() +
  scale_fill_gradient(low = "white", high = "red") +
  labs(title = "Heatmap Karakteristik Klaster K-Means",
       x = "Fitur",
       y = "Klaster") +
  theme_minimal()

Berdasarkan heatmap untuk hasil klasterisasi K-Means, kita dapat melihat pola karakteristik yang berbeda antar klaster berdasarkan empat fitur utama, yaitu Speed_Over_Ground_kn, Engine_Power_kW, Distance_Traveled_nm, dan Draft_meters. Warna merah yang lebih gelap menunjukkan nilai rata-rata yang lebih tinggi pada fitur tersebut dalam klaster tertentu.

  • Klaster 6 dan Klaster 8 menunjukkan warna yang lebih gelap pada fitur Engine_Power_kW dan Speed_Over_Ground_kn, yang mengindikasikan bahwa kedua klaster ini memiliki kapal dengan tenaga mesin dan kecepatan yang relatif tinggi.

  • Klaster 2 dan Klaster 4 tampak memiliki warna yang lebih terang pada sebagian besar fitur, menandakan bahwa kapal dalam kelompok ini cenderung memiliki ukuran dan performa yang lebih rendah.

  • Klaster 3 dan Klaster 5 memperlihatkan intensitas sedang pada hampir semua fitur, yang berarti memiliki karakteristik menengah antara kelompok cepat dan lambat.

Perbandingan Hasil Metode Ward’ dan K-Means

comparison_table <- data.frame(
  Method = c("Hierarchical (Ward's)", "K-Means"),
  Silhouette_Score = c(avg_silhouette, avg_silhouette_kmeans),
  Dunn_Index = c(dunn_index, dunn_index_kmeans),
  Calinski_Harabasz_Index = c(ch_index, ch_index_kmeans)
)
print(comparison_table)
##                  Method Silhouette_Score Dunn_Index Calinski_Harabasz_Index
## 1 Hierarchical (Ward's)        0.1459892 0.09443172                88.26635
## 2               K-Means        0.2509852 0.07520343               122.58729

Berdasarkan tabel perbandingan di atas: - Silhouette Score, metode K-Means menunjukkan nilai yang lebih tinggi (0.2509852) dibandingkan metode Ward (0.1459892). Hal ini mengindikasikan bahwa hasil klasterisasi K-Means memiliki pemisahan antar-klaster yang lebih baik dan objek-objek dalam satu klaster lebih homogen.

Kesimpulan

Secara keseluruhan, dapat disimpulkan bahwa metode K-Means cenderung memberikan hasil klasterisasi yang lebih baik secara umum, terutama dalam hal kekompakan dan pemisahan antar klaster berdasarkan nilai Silhouette Score dan Calinski-Harabasz Index.