Algoritma Fuzzy C-Means dengan R
Algoritma
Introduction
Clustering merupakan salah satu metode machine learning dan termasuk dalam unsupervised learning. Dalam unsupervised learning lebih fokus dalam melakukan eksplorasi data seperti mencari pola dalam data. Clustering sendiri bertujuan mencari pola data yang mirip sehingga memiliki kemungkinan dalam mengelompokkan data-data yang mirip tersebut.
Fuzzy C-means clustering
Fuzzy c-means merupakan salah satu jenis soft clustering di mana dalam mengelompokan suatu data, setiap data bisa dimiliki lebih dari satu cluster.
Cara kerja dari fuzzy c-means clustering dalam mengelompokkan datanya adalah sebagai berikut :
- Menentukan banyak cluster (k) yang akan dibuat.
- Menentukan nilai proporsi untuk setiap data poin secara random untuk masuk dalam suatu cluster.
- Menghitung nilai centroid. Dalam menghitung nilai centroid
objek data adalah anggota dari semua cluster dengan derajat keanggotaan fuzzy yang bervariasi antara 0 dan 1 dalam FCM. Oleh karena itu, objek data yang lebih dekat ke pusat cluster memiliki derajat keanggotaan yang lebih tinggi daripada objek yang tersebar di batas cluster.
Tahapan Algoritma Fuzzy C-means
1. Siapkan data set yang digunakan
Pada tahapan ini menggunakan data set Wine Quality.
2. Melakukan INISIALISASI:
- Menentukan jumlah cluster ( k>= 1)
- Menentukan bobot pangkat (w > 1)
- Menentukan jumlah maksimal iterasi
- Menentukan threshold perubahan fungsi obyektif.
3. Berikan nilai keanggotaan setiap data pada cluster secara acak.
Dengan syarat jumlah nilai pada keseluruhan cluster bernilai = 1
\[\begin{equation}\sum_{i=1}^k U i j=1\end{equation}\]
4. Menghitung nilai centroid.
Dalam menghitung nilai centroid, kita menggunakan formula berikut :
\[\begin{equation}C_j=\frac{\sum u_{i j}^m x}{\sum u_{i j}^m}\end{equation}\]
5. Menghitung kembali nilai proporsi untuk setiap data poin untuk masuk pada setiap cluster.
Formula yang digunakan yaitu sebagai berikut :
\[\begin{equation}u_{i j}^m=\frac{1}{\sum\left(\frac{\left|x_i-c_j\right|}{\left|x_i-c_k\right|}\right)^{\frac{2}{m-1}}}\end{equation}\]
Eksperimen Algoritma Fuzzy C-means
library
Sebelum memasukkan data, kita perlu memanggil library terlebih dahulu dan meng install beberapa packages yang tidak tersedia.
library(ppclust)
library(factoextra)
library(dplyr)
library(cluster)
library(fclust)Input Data set
Tahap ini digunakan untuk memanggil data set yang ingin digunakan pada algoritma Fuzzy c-means. Pada kali ini menggunakan data set Wine Quality.
library (readxl)
data <- read_excel("D:/MATKUL SMST 3/DATA MINING/algoritma-Fuzzy-C-Means/WINEQUality-red.xlsx")Memanggil dan menampilkan data set. Karena dari data wine ini mempunyai banyak data maka kita tampilkan n=10
data## # A tibble: 1,599 x 12
## fixed~1 volat~2 citri~3 resid~4 chlor~5 free ~6 total~7 density pH sulph~8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 7.4 0.7 0 1.9 0.076 11 34 0.998 3.51 0.56
## 2 7.8 0.88 0 2.6 0.098 25 67 0.997 3.2 0.68
## 3 7.8 0.76 0.04 2.3 0.092 15 54 0.997 3.26 0.65
## 4 11.2 0.28 0.56 1.9 0.075 17 60 0.998 3.16 0.58
## 5 7.4 0.7 0 1.9 0.076 11 34 0.998 3.51 0.56
## 6 7.4 0.66 0 1.8 0.075 13 40 0.998 3.51 0.56
## 7 7.9 0.6 0.06 1.6 0.069 15 59 0.996 3.3 0.46
## 8 7.3 0.65 0 1.2 0.065 15 21 0.995 3.39 0.47
## 9 7.8 0.58 0.02 2 0.073 9 18 0.997 3.36 0.57
## 10 7.5 0.5 0.36 6.1 0.071 17 102 0.998 3.35 0.8
## # ... with 1,589 more rows, 2 more variables: alcohol <dbl>, quality <dbl>, and
## # abbreviated variable names 1: `fixed acidity`, 2: `volatile acidity`,
## # 3: `citric acid`, 4: `residual sugar`, 5: chlorides,
## # 6: `free sulfur dioxide`, 7: `total sulfur dioxide`, 8: sulphates
data_wine = data
head (data_wine,n=10)## # A tibble: 10 x 12
## fixed~1 volat~2 citri~3 resid~4 chlor~5 free ~6 total~7 density pH sulph~8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 7.4 0.7 0 1.9 0.076 11 34 0.998 3.51 0.56
## 2 7.8 0.88 0 2.6 0.098 25 67 0.997 3.2 0.68
## 3 7.8 0.76 0.04 2.3 0.092 15 54 0.997 3.26 0.65
## 4 11.2 0.28 0.56 1.9 0.075 17 60 0.998 3.16 0.58
## 5 7.4 0.7 0 1.9 0.076 11 34 0.998 3.51 0.56
## 6 7.4 0.66 0 1.8 0.075 13 40 0.998 3.51 0.56
## 7 7.9 0.6 0.06 1.6 0.069 15 59 0.996 3.3 0.46
## 8 7.3 0.65 0 1.2 0.065 15 21 0.995 3.39 0.47
## 9 7.8 0.58 0.02 2 0.073 9 18 0.997 3.36 0.57
## 10 7.5 0.5 0.36 6.1 0.071 17 102 0.998 3.35 0.8
## # ... with 2 more variables: alcohol <dbl>, quality <dbl>, and abbreviated
## # variable names 1: `fixed acidity`, 2: `volatile acidity`, 3: `citric acid`,
## # 4: `residual sugar`, 5: chlorides, 6: `free sulfur dioxide`,
## # 7: `total sulfur dioxide`, 8: sulphates
Mengetahui Korelari antar variabel
Menampilkan Korelasi data wine 4 baris pertama
cor(data_wine [,1:4])## fixed acidity volatile acidity citric acid residual sugar
## fixed acidity 1.0000000 -0.256130895 0.6717034 0.114776724
## volatile acidity -0.2561309 1.000000000 -0.5524957 0.001917882
## citric acid 0.6717034 -0.552495685 1.0000000 0.143577162
## residual sugar 0.1147767 0.001917882 0.1435772 1.000000000
library(psych)Inisialisasi Data
Memanggil data dengan menentukan nilai cetroid, dengan pembagian K=5
library(ppclust)## Warning: package 'ppclust' was built under R version 4.1.3
res.fcm <- fcm(data_wine, centers=5)as.data.frame(res.fcm$u)[1:10,]## Cluster 1 Cluster 2 Cluster 3 Cluster 4 Cluster 5
## 1 0.025274316 0.0020591363 0.06844321 0.89819334 0.006029998
## 2 0.840824078 0.0114844663 0.01761281 0.04841328 0.081665364
## 3 0.647318267 0.0112451499 0.05046283 0.24177796 0.049195785
## 4 0.830402174 0.0089896358 0.02513874 0.08814917 0.047320279
## 5 0.025274316 0.0020591363 0.06844321 0.89819334 0.006029998
## 6 0.028189311 0.0015998028 0.02522306 0.93982489 0.005162930
## 7 0.769025278 0.0112569589 0.03483983 0.12787398 0.057003949
## 8 0.038670455 0.0047844540 0.70703317 0.23746536 0.012046564
## 9 0.004483022 0.0006447093 0.97082457 0.02248287 0.001564833
## 10 0.063136031 0.1075044822 0.01617797 0.02767444 0.785507082
Inisial Cluster awal (matriks prototype)
res.fcm$v0## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 9.3 0.36 0.39 1.5 0.080
## Cluster 2 7.9 0.69 0.21 2.1 0.080
## Cluster 3 8.6 0.37 0.65 6.4 0.080
## Cluster 4 7.0 0.22 0.30 1.8 0.065
## Cluster 5 7.0 0.60 0.30 4.5 0.068
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 41 55 0.99652 3.47 0.73
## Cluster 2 33 141 0.99620 3.25 0.51
## Cluster 3 3 8 0.99817 3.27 0.58
## Cluster 4 16 20 0.99672 3.61 0.82
## Cluster 5 20 110 0.99914 3.30 1.17
## alcohol quality
## Cluster 1 10.9 6
## Cluster 2 9.9 5
## Cluster 3 11.0 5
## Cluster 4 10.0 6
## Cluster 5 10.2 5
res.fcm$v## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 8.143923 0.5173805 0.2705070 2.441825 0.09386082
## Cluster 2 8.111173 0.5630854 0.3220769 3.113951 0.08833648
## Cluster 3 8.666728 0.5155081 0.2920574 2.434216 0.08550960
## Cluster 4 8.207523 0.5276560 0.2387213 2.322465 0.08650437
## Cluster 5 7.821936 0.5829549 0.2498367 2.879001 0.08685610
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 23.939370 59.46899 0.9968716 3.328914 0.6863725
## Cluster 2 29.764935 132.43278 0.9971610 3.235318 0.7120772
## Cluster 3 6.884509 17.23617 0.9966353 3.295084 0.6490544
## Cluster 4 14.542174 36.82602 0.9967029 3.336375 0.6455753
## Cluster 5 22.303909 91.44516 0.9968350 3.325858 0.6288155
## alcohol quality
## Cluster 1 10.309766 5.575234
## Cluster 2 9.774755 5.093139
## Cluster 3 10.654625 5.748832
## Cluster 4 10.425196 5.696972
## Cluster 5 10.111774 5.433166
summary(res.fcm)## Summary for 'res.fcm'
##
## Number of data objects: 1599
##
## Number of clusters: 5
##
## Crisp clustering vector:
## [1] 4 1 1 1 4 4 1 3 3 5 1 5 1 4 2 2 5 1 4 1 1 1 4 1 4 3 3 4 4 3 5 4 5 5 4 3 3
## [38] 4 3 5 5 4 3 3 3 1 2 4 3 5 3 3 3 2 1 4 3 2 1 4 1 5 4 1 3 3 4 3 1 3 4 5 5 4
## [75] 5 4 4 4 5 2 3 1 1 1 1 4 2 4 2 3 2 2 2 4 5 5 3 3 3 4 4 3 4 1 4 1 1 1 5 2 4
## [112] 5 5 4 4 1 4 3 1 5 5 1 3 4 5 5 3 3 3 3 2 5 5 4 4 1 1 4 5 5 1 1 1 3 1 2 5 5
## [149] 4 4 3 1 5 5 2 2 2 2 3 5 3 3 4 2 2 5 5 4 4 1 3 3 3 4 4 1 4 4 3 4 4 5 4 1 1
## [186] 5 1 3 2 2 2 1 2 3 3 2 1 4 5 4 3 2 4 4 4 4 4 2 5 3 3 1 3 1 4 2 4 4 4 2 1 1
## [223] 3 3 1 1 5 3 1 4 5 4 1 4 4 4 4 4 4 4 1 3 5 3 3 3 1 1 4 3 4 4 3 5 4 2 3 1 4
## [260] 4 4 1 4 1 3 3 1 4 3 3 1 3 1 4 5 1 3 3 3 4 3 3 1 4 1 1 1 1 1 5 1 3 4 3 1 3
## [297] 1 4 4 4 4 3 4 3 5 3 1 3 3 4 3 5 5 2 1 1 5 1 1 1 1 5 3 1 4 4 3 3 3 3 4 4 2
## [334] 4 4 3 3 1 5 4 3 3 3 3 4 1 4 3 4 4 4 3 3 5 2 4 1 4 3 4 5 1 4 3 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 1 5 4 3 1 4 4 4 4 4 5 5 1
## [1333] 3 4 3 4 4 4 4 4 4 4 4 4 3 4 3 3 3 4 1 4 1 1 3 4 3 1 5 3 4 1 3 1 4 4 4 5 1
## [1370] 3 1 3 1 5 4 5 4 1 4 4 4 3 5 5 5 5 3 3 4 2 4 4 3 1 1 3 3 5 4 3 2 2 3 3 4 4
## [1407] 3 1 1 1 3 3 3 5 3 3 3 4 3 2 3 1 1 4 3 3 1 3 1 1 4 1 3 3 5 5 5 4 3 5 4 5 4
## [1444] 3 5 5 4 4 1 4 4 3 1 5 3 3 5 5 3 3 1 3 4 4 1 1 1 4 1 1 3 3 4 4 5 5 5 5 3 3
## [1481] 3 3 3 3 3 3 3 3 3 3 3 3 3 2 4 4 2 3 3 3 3 1 1 3 3 3 3 3 4 3 1 4 3 1 1 1 1
## [1518] 4 3 4 4 3 1 1 1 4 4 3 1 1 3 4 3 5 4 4 4 4 4 1 4 1 4 3 3 4 4 3 1 3 4 4 1 4
## [1555] 3 3 3 3 2 2 2 2 3 3 3 4 1 3 4 4 4 3 5 1 5 3 4 4 3 4 3 4 4 5 4 1 1 4 5 5 4
## [1592] 4 4 4 1 1 4 1 4
##
## Initial cluster prototypes:
## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 9.3 0.36 0.39 1.5 0.080
## Cluster 2 7.9 0.69 0.21 2.1 0.080
## Cluster 3 8.6 0.37 0.65 6.4 0.080
## Cluster 4 7.0 0.22 0.30 1.8 0.065
## Cluster 5 7.0 0.60 0.30 4.5 0.068
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 41 55 0.99652 3.47 0.73
## Cluster 2 33 141 0.99620 3.25 0.51
## Cluster 3 3 8 0.99817 3.27 0.58
## Cluster 4 16 20 0.99672 3.61 0.82
## Cluster 5 20 110 0.99914 3.30 1.17
## alcohol quality
## Cluster 1 10.9 6
## Cluster 2 9.9 5
## Cluster 3 11.0 5
## Cluster 4 10.0 6
## Cluster 5 10.2 5
##
## Final cluster prototypes:
## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 8.143923 0.5173805 0.2705070 2.441825 0.09386082
## Cluster 2 8.111173 0.5630854 0.3220769 3.113951 0.08833649
## Cluster 3 8.666728 0.5155081 0.2920574 2.434216 0.08550961
## Cluster 4 8.207523 0.5276560 0.2387213 2.322465 0.08650437
## Cluster 5 7.821936 0.5829549 0.2498367 2.879001 0.08685610
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 23.939370 59.46899 0.9968716 3.328914 0.6863725
## Cluster 2 29.764935 132.43278 0.9971610 3.235318 0.7120772
## Cluster 3 6.884509 17.23617 0.9966353 3.295084 0.6490544
## Cluster 4 14.542174 36.82602 0.9967029 3.336375 0.6455753
## Cluster 5 22.303909 91.44516 0.9968350 3.325858 0.6288155
## alcohol quality
## Cluster 1 10.309766 5.575234
## Cluster 2 9.774755 5.093139
## Cluster 3 10.654625 5.748832
## Cluster 4 10.425196 5.696972
## Cluster 5 10.111774 5.433166
##
## Distance between the final cluster prototypes
## Cluster 1 Cluster 2 Cluster 3 Cluster 4
## Cluster 2 5358.6378
## Cluster 3 2074.9042 13795.7568
## Cluster 4 601.0607 9373.8315 442.6851
## Cluster 5 1025.5127 1736.0406 5746.0448 3044.1251
##
## Difference between the initial and final cluster prototypes
## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 -1.15607684 0.15738053 -0.11949304 0.9418248 0.013860820
## Cluster 2 0.21117281 -0.12691463 0.11207689 1.0139509 0.008336485
## Cluster 3 0.06672836 0.14550814 -0.35794260 -3.9657841 0.005509605
## Cluster 4 1.20752335 0.30765600 -0.06127869 0.5224648 0.021504368
## Cluster 5 0.82193561 -0.01704505 -0.05016334 -1.6209994 0.018856098
## free sulfur dioxide total sulfur dioxide density pH
## Cluster 1 -17.060630 4.468986 0.000351607 -0.14108626
## Cluster 2 -3.235065 -8.567222 0.000961033 -0.01468183
## Cluster 3 3.884509 9.236174 -0.001534724 0.02508367
## Cluster 4 -1.457826 16.826017 -0.000017093 -0.27362530
## Cluster 5 2.303909 -18.554841 -0.002305005 0.02585826
## sulphates alcohol quality
## Cluster 1 -0.04362752 -0.59023358 -0.42476566
## Cluster 2 0.20207717 -0.12524454 0.09313875
## Cluster 3 0.06905443 -0.34537476 0.74883232
## Cluster 4 -0.17442470 0.42519631 -0.30302814
## Cluster 5 -0.54118455 -0.08822568 0.43316577
##
## Root Mean Squared Deviations (RMSD): 15.20971
## Mean Absolute Deviation (MAD): 248.9766
##
## Membership degrees matrix (top and bottom 5 rows):
## Cluster 1 Cluster 2 Cluster 3 Cluster 4 Cluster 5
## 1 0.02527432 0.002059136 0.06844321 0.89819334 0.006029998
## 2 0.84082408 0.011484466 0.01761281 0.04841328 0.081665364
## 3 0.64731827 0.011245150 0.05046283 0.24177797 0.049195785
## 4 0.83040217 0.008989636 0.02513874 0.08814917 0.047320279
## 5 0.02527432 0.002059136 0.06844321 0.89819334 0.006029998
## ...
## Cluster 1 Cluster 2 Cluster 3 Cluster 4 Cluster 5
## 1595 0.4436455 0.017487334 0.10113639 0.3794291 0.05830166
## 1596 0.5806642 0.026306691 0.08117201 0.2197260 0.09213111
## 1597 0.2911772 0.013919470 0.11747811 0.5332653 0.04415990
## 1598 0.4433518 0.017545074 0.10134779 0.3792782 0.05847719
## 1599 0.1082961 0.004516323 0.05042296 0.8215353 0.01522923
##
## Descriptive statistics for the membership degrees by clusters
## Size Min Q1 Mean Median Q3 Max
## Cluster 1 320 0.3455386 0.5549501 0.6915114 0.6836992 0.8166995 0.9975386
## Cluster 2 81 0.3566488 0.6983723 0.7836378 0.8383926 0.9135432 0.9964588
## Cluster 3 543 0.4728023 0.8324747 0.8631094 0.9133480 0.9550126 0.9950462
## Cluster 4 464 0.4205281 0.5897926 0.7306091 0.7378001 0.8720060 0.9901855
## Cluster 5 191 0.3598101 0.5631595 0.7298961 0.7722294 0.8658661 0.9940375
##
## Dunn's Fuzziness Coefficients:
## dunn_coeff normalized
## 0.6660324 0.5825405
##
## Within cluster sum of squares by cluster:
## 1 2 3 4 5
## 49276.20 71336.89 24932.46 37075.86 41489.93
## (between_SS / total_SS = 87.95%)
##
## Available components:
## [1] "u" "v" "v0" "d" "x"
## [6] "cluster" "csize" "sumsqrs" "k" "m"
## [11] "iter" "best.start" "func.val" "comp.time" "inpargs"
## [16] "algorithm" "call"
Run FCM with Multiple Starts
library(ppclust)
res.fcm <- fcm(data_wine, centers=5, nstart=5)
res.fcm$func.val## [1] 128957.6 157733.5 128957.6 128957.6 157733.5
res.fcm$iter## [1] 134 268 144 132 295
res.fcm$best.start## [1] 4
summary(res.fcm)## Summary for 'res.fcm'
##
## Number of data objects: 1599
##
## Number of clusters: 5
##
## Crisp clustering vector:
## [1] 4 2 2 2 4 4 2 1 1 5 2 5 2 4 3 3 5 2 4 2 2 2 4 2 4 1 1 4 4 1 5 4 5 5 4 1 1
## [38] 4 1 5 5 4 1 1 1 2 3 4 1 5 1 1 1 3 2 4 1 3 2 4 2 5 4 2 1 1 4 1 2 1 4 5 5 4
## [75] 5 4 4 4 5 3 1 2 2 2 2 4 3 4 3 1 3 3 3 4 5 5 1 1 1 4 4 1 4 2 4 2 2 2 5 3 4
## [112] 5 5 4 4 2 4 1 2 5 5 2 1 4 5 5 1 1 1 1 3 5 5 4 4 2 2 4 5 5 2 2 2 1 2 3 5 5
## [149] 4 4 1 2 5 5 3 3 3 3 1 5 1 1 4 3 3 5 5 4 4 2 1 1 1 4 4 2 4 4 1 4 4 5 4 2 2
## [186] 5 2 1 3 3 3 2 3 1 1 3 2 4 5 4 1 3 4 4 4 4 4 3 5 1 1 2 1 2 4 3 4 4 4 3 2 2
## [223] 1 1 2 2 5 1 2 4 5 4 2 4 4 4 4 4 4 4 2 1 5 1 1 1 2 2 4 1 4 4 1 5 4 3 1 2 4
## [260] 4 4 2 4 2 1 1 2 4 1 1 2 1 2 4 5 2 1 1 1 4 1 1 2 4 2 2 2 2 2 5 2 1 4 1 2 1
## [297] 2 4 4 4 4 1 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] 4 4 2 1 2 1 2 4 4 1 2 5 2 2 4 2 4 5 1 1 5 1 2 2 1 2 4 4 4 1 5 5 1 2 4 1 2
## [1296] 5 5 4 1 1 4 2 1 2 2 5 5 4 5 2 5 4 4 2 2 5 4 4 5 2 5 4 1 2 4 4 4 4 4 5 5 2
## [1333] 1 4 1 4 4 4 4 4 4 4 4 4 1 4 1 1 1 4 2 4 2 2 1 4 1 2 5 1 4 2 1 2 4 4 4 5 2
## [1370] 1 2 1 2 5 4 5 4 2 4 4 4 1 5 5 5 5 1 1 4 3 4 4 1 2 2 1 1 5 4 1 3 3 1 1 4 4
## [1407] 1 2 2 2 1 1 1 5 1 1 1 4 1 3 1 2 2 4 1 1 2 1 2 2 4 2 1 1 5 5 5 4 1 5 4 5 4
## [1444] 1 5 5 4 4 2 4 4 1 2 5 1 1 5 5 1 1 2 1 4 4 2 2 2 4 2 2 1 1 4 4 5 5 5 5 1 1
## [1481] 1 1 1 1 1 1 1 1 1 1 1 1 1 3 4 4 3 1 1 1 1 2 2 1 1 1 1 1 4 1 2 4 1 2 2 2 2
## [1518] 4 1 4 4 1 2 2 2 4 4 1 2 2 1 4 1 5 4 4 4 4 4 2 4 2 4 1 1 4 4 1 2 1 4 4 2 4
## [1555] 1 1 1 1 3 3 3 3 1 1 1 4 2 1 4 4 4 1 5 2 5 1 4 4 1 4 1 4 4 5 4 2 2 4 5 5 4
## [1592] 4 4 4 2 2 4 2 4
##
## Initial cluster prototypes:
## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 9.9 0.59 0.07 3.4 0.102
## Cluster 2 7.8 0.56 0.19 2.0 0.081
## Cluster 3 7.6 0.54 0.02 1.7 0.085
## Cluster 4 7.9 0.30 0.68 8.3 0.050
## Cluster 5 6.8 0.36 0.32 1.8 0.067
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 32.0 71 1.00015 3.31 0.71
## Cluster 2 17.0 108 0.99620 3.32 0.54
## Cluster 3 17.0 31 0.99589 3.37 0.51
## Cluster 4 37.5 278 0.99316 3.01 0.51
## Cluster 5 4.0 8 0.99280 3.36 0.55
## alcohol quality
## Cluster 1 9.8 5
## Cluster 2 9.5 5
## Cluster 3 10.4 6
## Cluster 4 12.3 7
## Cluster 5 12.8 7
##
## Final cluster prototypes:
## fixed acidity volatile acidity citric acid residual sugar chlorides
## Cluster 1 8.666728 0.5155081 0.2920574 2.434216 0.08550961
## Cluster 2 8.143923 0.5173805 0.2705070 2.441825 0.09386082
## Cluster 3 8.111173 0.5630854 0.3220769 3.113951 0.08833649
## Cluster 4 8.207523 0.5276560 0.2387213 2.322465 0.08650437
## Cluster 5 7.821936 0.5829549 0.2498367 2.879001 0.08685610
## free sulfur dioxide total sulfur dioxide density pH sulphates
## Cluster 1 6.884509 17.23617 0.9966353 3.295084 0.6490544
## Cluster 2 23.939370 59.46899 0.9968716 3.328914 0.6863725
## Cluster 3 29.764935 132.43278 0.9971610 3.235318 0.7120772
## Cluster 4 14.542174 36.82602 0.9967029 3.336375 0.6455753
## Cluster 5 22.303909 91.44516 0.9968350 3.325858 0.6288155
## alcohol quality
## Cluster 1 10.654625 5.748832
## Cluster 2 10.309766 5.575234
## Cluster 3 9.774755 5.093139
## Cluster 4 10.425196 5.696972
## Cluster 5 10.111774 5.433166
##
## Distance between the final cluster prototypes
## Cluster 1 Cluster 2 Cluster 3 Cluster 4
## Cluster 2 2074.9042
## Cluster 3 13795.7568 5358.6378
## Cluster 4 442.6851 601.0607 9373.8315
## Cluster 5 5746.0448 1025.5127 1736.0406 3044.1251
##
## Difference between the initial and final cluster prototypes
## fixed acidity volatile acidity citric acid residual sugar
## Cluster 1 -1.2332716 -0.07449186 0.22205740 -0.9657841
## Cluster 2 0.3439232 -0.04261947 0.08050696 0.4418248
## Cluster 3 0.5111728 0.02308537 0.30207689 1.4139509
## Cluster 4 0.3075233 0.22765599 -0.44127869 -5.9775352
## Cluster 5 1.0219356 0.22295495 -0.07016334 1.0790006
## chlorides free sulfur dioxide total sulfur dioxide density
## Cluster 1 -0.016490395 -25.11549 -53.76383 -0.003514724
## Cluster 2 0.012860820 6.93937 -48.53101 0.000671607
## Cluster 3 0.003336485 12.76493 101.43278 0.001271033
## Cluster 4 0.036504368 -22.95783 -241.17398 0.003542907
## Cluster 5 0.019856098 18.30391 83.44516 0.004034995
## pH sulphates alcohol quality
## Cluster 1 -0.014916334 -0.06094557 0.8546252 0.7488323
## Cluster 2 0.008913742 0.14637248 0.8097664 0.5752343
## Cluster 3 -0.134681827 0.20207717 -0.6252445 -0.9068613
## Cluster 4 0.326374700 0.13557530 -1.8748037 -1.3030281
## Cluster 5 -0.034141735 0.07881545 -2.6882257 -1.5668342
##
## Root Mean Squared Deviations (RMSD): 128.3967
## Mean Absolute Deviation (MAD): 1542.311
##
## Membership degrees matrix (top and bottom 5 rows):
## Cluster 1 Cluster 2 Cluster 3 Cluster 4 Cluster 5
## 1 0.06844321 0.02527432 0.002059136 0.89819334 0.006029998
## 2 0.01761281 0.84082408 0.011484466 0.04841328 0.081665364
## 3 0.05046283 0.64731827 0.011245150 0.24177797 0.049195785
## 4 0.02513874 0.83040217 0.008989636 0.08814917 0.047320279
## 5 0.06844321 0.02527432 0.002059136 0.89819334 0.006029998
## ...
## Cluster 1 Cluster 2 Cluster 3 Cluster 4 Cluster 5
## 1595 0.10113639 0.4436455 0.017487334 0.3794291 0.05830166
## 1596 0.08117201 0.5806642 0.026306691 0.2197260 0.09213111
## 1597 0.11747811 0.2911772 0.013919470 0.5332653 0.04415990
## 1598 0.10134779 0.4433518 0.017545074 0.3792782 0.05847719
## 1599 0.05042296 0.1082961 0.004516323 0.8215353 0.01522923
##
## Descriptive statistics for the membership degrees by clusters
## Size Min Q1 Mean Median Q3 Max
## Cluster 1 543 0.4728023 0.8324747 0.8631094 0.9133480 0.9550126 0.9950462
## Cluster 2 320 0.3455386 0.5549501 0.6915114 0.6836992 0.8166995 0.9975386
## Cluster 3 81 0.3566488 0.6983723 0.7836378 0.8383926 0.9135432 0.9964588
## Cluster 4 464 0.4205281 0.5897926 0.7306091 0.7378001 0.8720060 0.9901855
## Cluster 5 191 0.3598101 0.5631595 0.7298961 0.7722294 0.8658661 0.9940375
##
## Dunn's Fuzziness Coefficients:
## dunn_coeff normalized
## 0.6660324 0.5825405
##
## Within cluster sum of squares by cluster:
## 1 2 3 4 5
## 24932.46 49276.20 71336.89 37075.86 41489.93
## (between_SS / total_SS = 87.95%)
##
## Available components:
## [1] "u" "v" "v0" "d" "x"
## [6] "cluster" "csize" "sumsqrs" "k" "m"
## [11] "iter" "best.start" "func.val" "comp.time" "inpargs"
## [16] "algorithm" "call"