Contexto

La segmentación o clusters es un conjutno de técnicas cuyo propósito es formar grupos a partir de un conjunto de elementos.

Más información: R for Data Science (2ed)

Paso 1. Instalar paquetes y llamar librerías

#install.packages('clusters')
library(cluster)
#install.packages('ggplot2')
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.1
#install.packages('data.table')
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.1
#install.packages('factoextra')
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa

Paso 2. Obtener los datos

df <- read.csv('/Users/genarorodriguezalcantara/Desktop/Tec/AI - Concentración/Módulo 2 - Machine Learning/BD/wine.csv')

Paso 3. Exploración inicial de datos

summary(df)
##     Alcohol        Malic_Acid         Ash         Ash_Alcanity  
##  Min.   :11.03   Min.   :0.740   Min.   :1.360   Min.   :10.60  
##  1st Qu.:12.36   1st Qu.:1.603   1st Qu.:2.210   1st Qu.:17.20  
##  Median :13.05   Median :1.865   Median :2.360   Median :19.50  
##  Mean   :13.00   Mean   :2.336   Mean   :2.367   Mean   :19.49  
##  3rd Qu.:13.68   3rd Qu.:3.083   3rd Qu.:2.558   3rd Qu.:21.50  
##  Max.   :14.83   Max.   :5.800   Max.   :3.230   Max.   :30.00  
##    Magnesium      Total_Phenols     Flavanoids    Nonflavanoid_Phenols
##  Min.   : 70.00   Min.   :0.980   Min.   :0.340   Min.   :0.1300      
##  1st Qu.: 88.00   1st Qu.:1.742   1st Qu.:1.205   1st Qu.:0.2700      
##  Median : 98.00   Median :2.355   Median :2.135   Median :0.3400      
##  Mean   : 99.74   Mean   :2.295   Mean   :2.029   Mean   :0.3619      
##  3rd Qu.:107.00   3rd Qu.:2.800   3rd Qu.:2.875   3rd Qu.:0.4375      
##  Max.   :162.00   Max.   :3.880   Max.   :5.080   Max.   :0.6600      
##  Proanthocyanins Color_Intensity       Hue             OD280      
##  Min.   :0.410   Min.   : 1.280   Min.   :0.4800   Min.   :1.270  
##  1st Qu.:1.250   1st Qu.: 3.220   1st Qu.:0.7825   1st Qu.:1.938  
##  Median :1.555   Median : 4.690   Median :0.9650   Median :2.780  
##  Mean   :1.591   Mean   : 5.058   Mean   :0.9574   Mean   :2.612  
##  3rd Qu.:1.950   3rd Qu.: 6.200   3rd Qu.:1.1200   3rd Qu.:3.170  
##  Max.   :3.580   Max.   :13.000   Max.   :1.7100   Max.   :4.000  
##     Proline      
##  Min.   : 278.0  
##  1st Qu.: 500.5  
##  Median : 673.5  
##  Mean   : 746.9  
##  3rd Qu.: 985.0  
##  Max.   :1680.0

Paso 4. Procesamiento de datos

Suponiendo que se seleccionan las variables de interés

#df <- wine_data[, c("Alcohol", "Malic_Acid", "Ash", "Color_Intensity", "Ash_Alcanity", "Magnesium", "Total_Phenols", "Flavanoids", "Nonflavanoid_Phenols", "Proanthocyanins", "Hue", "OD280", "Proline")]

Paso 5. Cantidad de grupos

df <- scale(df)
grupos <- 3

Paso 6. Generar los segmentos

segmentos <- kmeans(df, grupos, nstart = 1)
segmentos
## K-means clustering with 3 clusters of sizes 62, 51, 65
## 
## Cluster means:
##      Alcohol Malic_Acid        Ash Ash_Alcanity   Magnesium Total_Phenols
## 1  0.8328826 -0.3029551  0.3636801   -0.6084749  0.57596208    0.88274724
## 2  0.1644436  0.8690954  0.1863726    0.5228924 -0.07526047   -0.97657548
## 3 -0.9234669 -0.3929331 -0.4931257    0.1701220 -0.49032869   -0.07576891
##    Flavanoids Nonflavanoid_Phenols Proanthocyanins Color_Intensity        Hue
## 1  0.97506900          -0.56050853      0.57865427       0.1705823  0.4726504
## 2 -1.21182921           0.72402116     -0.77751312       0.9388902 -1.1615122
## 3  0.02075402          -0.03343924      0.05810161      -0.8993770  0.4605046
##        OD280    Proline
## 1  0.7770551  1.1220202
## 2 -1.2887761 -0.4059428
## 3  0.2700025 -0.7517257
## 
## 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 3 3 2 3 3 3 3 3 3 3 3 3 3 3 1
##  [75] 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [112] 3 3 3 3 3 3 3 2 3 3 1 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [149] 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
## 
## Within cluster sum of squares by cluster:
## [1] 385.6983 326.3537 558.6971
##  (between_SS / total_SS =  44.8 %)
## 
## Available components:
## 
## [1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
## [6] "betweenss"    "size"         "iter"         "ifault"

Paso 7. Asignar el grupo al que pertenece cada observación

asignacion <- cbind(df, cluster = segmentos$cluster)
asignacion
##            Alcohol  Malic_Acid         Ash Ash_Alcanity   Magnesium
##   [1,]  1.51434077 -0.56066822  0.23139979 -1.166303174  1.90852151
##   [2,]  0.24559683 -0.49800856 -0.82566722 -2.483840525  0.01809398
##   [3,]  0.19632522  0.02117152  1.10621386 -0.267982252  0.08810981
##   [4,]  1.68679140 -0.34583508  0.48655389 -0.806974805  0.92829983
##   [5,]  0.29486844  0.22705328  1.83522559  0.450674485  1.27837900
##   [6,]  1.47738706 -0.51591132  0.30430096 -1.286079296  0.85828399
##   [7,]  1.71142720 -0.41744613  0.30430096 -1.465743481 -0.26196936
##   [8,]  1.30493643 -0.16680747  0.88751034 -0.567422559  1.48842650
##   [9,]  2.25341491 -0.62332789 -0.71631546 -1.645407665 -0.19195352
##  [10,]  1.05857838 -0.88291793 -0.35180959 -1.046527051 -0.12193769
##  [11,]  1.35420804 -0.15785609 -0.24245783 -0.447646437  0.36817315
##  [12,]  1.37884384 -0.76654998 -0.16955666 -0.806974805 -0.33198519
##  [13,]  0.92308146 -0.54276546  0.15849862 -1.046527051 -0.75208020
##  [14,]  2.15487169 -0.54276546  0.08559744 -2.423952463 -0.61204853
##  [15,]  1.69910930 -0.41744613  0.04914686 -2.244288279  0.15812565
##  [16,]  0.77526663 -0.47115441  1.21556562 -0.687198682  0.85828399
##  [17,]  1.60056608 -0.37268923  1.28846679  0.151234178  1.41841067
##  [18,]  1.02162467 -0.68598755  0.92396093  0.151234178  1.06833150
##  [19,]  1.46506916 -0.66808479  0.41365272 -0.896806897  0.57822065
##  [20,]  0.78758453  0.68357369  0.70525741 -1.286079296  1.13834733
##  [21,]  1.30493643 -0.63227927 -0.31535901 -1.046527051  1.83850567
##  [22,] -0.08698653  1.31017034  1.03331269 -0.267982252  0.15812565
##  [23,]  0.87380985 -0.42639751 -0.02375431 -0.866862867  0.08810981
##  [24,] -0.18552975 -0.65913341  0.55945507 -0.507534498 -0.33198519
##  [25,]  0.61513390 -0.47115441  0.88751034  0.151234178 -0.26196936
##  [26,]  0.06082829 -0.25632128  3.11099611  1.648435713  1.69847400
##  [27,]  0.47963697 -0.50695994  0.92396093 -1.016583020 -0.47201686
##  [28,]  0.36877585 -0.55171684 -0.82566722 -0.747086744 -0.40200103
##  [29,]  1.07089628 -0.39059199  1.58007149 -0.028430007  0.50820482
##  [30,]  1.25566482 -0.58752236 -0.57051311 -1.046527051 -0.26196936
##  [31,]  0.89844565 -0.74864721  1.21556562  0.899834945  0.08810981
##  [32,]  0.71367712 -0.60542512 -0.02375431 -0.118262099  0.43818899
##  [33,]  0.83685614 -0.45325165 -0.02375431 -0.687198682  0.29815732
##  [34,]  0.93539936 -0.72179307  1.21556562  0.001514024  2.25860068
##  [35,]  0.62745180 -0.48010579  1.03331269 -0.148206130  0.71825232
##  [36,]  0.59049809 -0.47115441  0.15849862  0.300954331  0.01809398
##  [37,]  0.34414005 -0.62332789  1.72587383 -1.196247204  0.71825232
##  [38,]  0.06082829 -0.61437650  0.66880683 -0.447646437 -0.12193769
##  [39,]  0.08546410 -0.74864721 -0.97146956 -1.196247204 -0.12193769
##  [40,]  1.50202286  1.48024658  0.52300448 -1.884959911  1.97853734
##  [41,]  0.68904131 -0.56066822 -0.20600725 -0.986638989  1.20836316
##  [42,]  0.50427278  1.34597587 -0.89856839 -0.208094191 -0.68206436
##  [43,]  1.08321419 -0.39954337  0.81460917 -1.345967358  0.08810981
##  [44,]  0.29486844  1.47129519 -0.27890842 -0.597366590  0.22814148
##  [45,]  0.06082829 -0.50695994 -0.97146956 -0.747086744  0.50820482
##  [46,]  1.48970496  1.52500348  0.26785038 -0.178150160  0.78826816
##  [47,]  1.69910930  1.12219135 -0.31535901 -1.046527051  0.15812565
##  [48,]  1.10784999 -0.58752236 -0.89856839 -1.046527051  0.08810981
##  [49,]  1.35420804 -0.28317542  0.12204803 -0.208094191  0.22814148
##  [50,]  1.15712160 -0.54276546 -0.35180959 -0.627310621  0.57822065
##  [51,]  0.06082829 -0.54276546 -1.19017308 -2.124512156 -0.54203270
##  [52,]  1.02162467 -0.61437650  0.85105976 -0.687198682 -0.40200103
##  [53,]  1.00930677 -0.52486270  0.19494920 -1.645407665  0.78826816
##  [54,]  0.94771726 -0.39059199  1.14266445 -0.717142713  1.06833150
##  [55,]  0.91076355 -0.59647374 -0.42471076 -0.926750928  1.27837900
##  [56,]  0.68904131 -0.54276546  0.34075155  0.300954331  1.13834733
##  [57,]  1.50202286 -0.56961960 -0.24245783 -0.956694959  1.27837900
##  [58,]  0.35645795 -0.32793232  1.14266445 -0.806974805  0.15812565
##  [59,]  0.88612775 -0.81130688  0.48655389 -0.836918836  0.57822065
##  [60,] -0.77678907 -1.24992453 -3.66881295 -2.663504709 -0.82209603
##  [61,] -0.82606067 -1.10670244 -0.31535901 -1.046527051  0.08810981
##  [62,] -0.44420570 -0.87396654 -1.26307425 -0.806974805  0.01809398
##  [63,]  0.82453824 -0.97243173 -1.62758012 -0.447646437 -0.40200103
##  [64,] -0.77678907 -1.07984830 -0.75276604 -0.148206130 -0.89211187
##  [65,] -1.02314711 -0.79340412  0.59590565 -0.148206130  0.29815732
##  [66,] -0.77678907 -1.00823725  0.70525741 -0.417702406 -0.12193769
##  [67,]  0.13473571 -1.18726487 -2.42949302 -1.345967358 -1.52225438
##  [68,] -0.77678907 -1.04404278 -1.62758012  0.031458055 -1.52225438
##  [69,]  0.41804746 -1.24992453 -0.02375431 -0.747086744  0.71825232
##  [70,] -0.97387550 -1.02614002 -2.24724008 -0.806974805  3.58890153
##  [71,] -0.87533228 -0.65018203 -0.57051311  0.271010300  0.22814148
##  [72,]  1.05857838 -0.73969583  1.10621386  1.648435713 -0.96212770
##  [73,]  0.60281600 -0.60542512 -0.46116135  1.348995406 -0.89211187
##  [74,] -0.01307912 -0.59647374  0.85105976  3.145637249  2.74871152
##  [75,] -1.28182306 -1.11565382 -0.24245783  0.450674485  0.08810981
##  [76,] -1.65136013 -0.40849475 -1.62758012 -1.046527051 -0.19195352
##  [77,]  0.03619249 -1.28573006 -2.39304243 -1.046527051 -0.96212770
##  [78,] -1.42963789  0.49559470 -0.49761194 -0.447646437  0.85828399
##  [79,] -0.82606067 -1.20516763 -1.51822836 -1.405855419  2.53866402
##  [80,] -0.37029829  1.37283001  0.12204803  1.049555099  0.08810981
##  [81,] -1.23255145 -1.26782729 -1.33597542 -0.148206130 -0.96212770
##  [82,] -0.34566248 -0.47115441 -0.60696370 -0.208094191 -0.96212770
##  [83,] -1.13400823 -1.07984830  0.52300448  1.348995406 -1.52225438
##  [84,]  0.06082829  1.36387863 -0.16955666  0.899834945 -1.03214354
##  [85,] -1.42963789 -1.29468144  0.77815859 -0.447646437 -0.40200103
##  [86,] -0.40725200 -1.21411901 -0.46116135 -0.447646437 -0.05192185
##  [87,] -1.03546501 -0.65018203 -0.20600725  0.989667037 -0.68206436
##  [88,] -1.66367803 -0.59647374  0.92396093  1.947876020 -0.82209603
##  [89,] -1.67599593 -0.24736990  0.34075155  0.630338669 -1.10215937
##  [90,] -1.13400823 -0.90082069 -0.24245783  1.229219283 -2.08238105
##  [91,] -1.13400823 -0.45325165 -0.16955666 -0.297926283 -1.31220687
##  [92,] -1.23255145 -0.73969583  0.19494920  0.750114792 -0.96212770
##  [93,] -0.38261619 -0.72179307 -0.38826018  0.360842393 -1.38222271
##  [94,] -0.87533228  0.44188642 -0.53406252 -0.447646437 -0.82209603
##  [95,] -1.70063174 -0.31002956 -0.31535901 -0.447646437 -0.12193769
##  [96,] -0.65361004 -0.73074445 -0.60696370 -0.148206130  4.35907571
##  [97,] -1.46659160 -0.19366161  1.36136797  0.600394638  2.39863235
##  [98,] -0.87533228 -0.82920964 -1.40887660 -1.046527051 -1.03214354
##  [99,] -0.77678907 -1.13355658 -0.97146956 -0.297926283 -0.82209603
## [100,] -0.87533228  0.74623336 -0.57051311 -0.447646437 -0.82209603
## [101,] -1.13400823 -0.22946714 -2.42949302 -0.597366590 -0.19195352
## [102,] -0.49347731 -0.89186931 -1.70048129 -0.297926283 -0.82209603
## [103,] -0.81374277  0.10173395  0.34075155  0.450674485 -0.12193769
## [104,] -1.45427369 -0.55171684 -1.77338246  0.001514024 -0.96212770
## [105,] -0.60433843 -0.54276546 -1.40887660  0.300954331 -1.03214354
## [106,] -0.71519955  0.19124776 -0.35180959  0.750114792 -0.68206436
## [107,] -0.92460389 -0.54276546 -0.89856839 -0.148206130 -1.38222271
## [108,] -0.34566248 -0.52486270 -0.31535901  0.899834945 -1.10215937
## [109,] -0.96155760 -0.93662621 -1.55467894 -0.148206130 -0.54203270
## [110,] -1.71294964 -0.88291793  1.21556562  0.151234178 -0.40200103
## [111,] -1.89771818  1.25646206 -1.99208598  0.001514024  0.50820482
## [112,] -0.59202053  0.08383119 -0.71631546  0.450674485 -0.82209603
## [113,] -1.52818111  0.30761571  2.01747852  0.151234178  0.22814148
## [114,] -1.95930769 -1.42895215  0.48655389  0.450674485 -0.82209603
## [115,] -1.13400823 -0.84711240  0.48655389  0.899834945 -1.10215937
## [116,] -2.42738798 -0.73969583 -0.60696370  0.600394638 -1.03214354
## [117,] -1.45427369 -0.77550136 -1.37242601  0.390786423 -0.96212770
## [118,] -0.71519955 -0.65018203 -0.64341428  0.899834945  0.57822065
## [119,] -0.28407297  0.97896926 -1.40887660 -1.046527051 -1.38222271
## [120,] -1.23255145  0.97896926 -1.33597542 -0.148206130 -0.89211187
## [121,] -1.91003608  0.05697705  0.19494920  0.151234178 -0.26196936
## [122,] -1.77453915 -0.25632128  3.14744670  2.696476788  1.34839483
## [123,] -0.71519955  1.87410733  1.32491738  2.097596174  0.15812565
## [124,]  0.06082829  3.10044648 -0.86211780  0.600394638 -0.96212770
## [125,] -1.39268418  1.76669076  0.08559744  0.450674485 -1.24219104
## [126,] -1.14632613 -0.15785609 -0.71631546  0.450674485 -1.03214354
## [127,] -0.70288165 -0.72179307 -0.27890842  0.600394638 -0.96212770
## [128,] -1.49122740 -0.18471023  1.50717031  2.696476788 -0.54203270
## [129,] -0.77678907 -0.63227927 -0.24245783  1.498715559 -0.82209603
## [130,] -1.18327984  1.75773938  0.04914686  0.750114792 -1.38222271
## [131,] -0.17321185 -0.88291793 -0.16955666 -0.447646437  1.55844234
## [132,] -0.14857605  0.58510851  0.12204803  0.151234178  0.29815732
## [133,] -0.23480136 -0.02358538  0.12204803  1.348995406 -0.12193769
## [134,] -0.37029829  1.08638583 -0.02375431  0.600394638  0.43818899
## [135,] -0.60433843 -0.98138311 -0.42471076 -0.597366590 -1.03214354
## [136,] -0.49347731  0.11068533 -0.60696370 -0.297926283 -0.40200103
## [137,] -0.92460389  2.13369737  0.63235624  0.450674485 -0.75208020
## [138,] -0.57970263  2.84085644  0.99686210  1.648435713 -0.26196936
## [139,]  0.60281600  1.12219135 -0.64341428  0.001514024 -0.82209603
## [140,] -0.19784766  0.55825437  0.88751034  1.348995406  0.08810981
## [141,] -0.08698653  0.42398365  1.21556562  0.450674485 -0.26196936
## [142,]  0.44268327  0.20019914 -0.06020490  0.151234178 -0.75208020
## [143,]  0.63976970  0.74623336  1.28846679  1.199275252 -0.19195352
## [144,]  0.76294873  2.33957912 -0.06020490  0.151234178 -0.54203270
## [145,] -0.92460389  1.38178139 -0.60696370 -0.297926283  0.85828399
## [146,]  0.19632522  1.10428859 -0.78921663  0.450674485  0.15812565
## [147,]  1.08321419  2.42014155 -0.49761194  0.151234178 -1.38222271
## [148,] -0.16089395  2.03523218  0.41365272  0.600394638 -0.96212770
## [149,]  0.39341166  0.80889302  0.04914686  0.600394638 -0.54203270
## [150,]  0.09778200  1.39968415 -0.02375431  0.600394638  0.92829983
## [151,]  0.61513390  0.70147646  0.92396093  1.348995406  1.62845817
## [152,] -0.25943717  0.29866433  0.41365272  0.750114792  0.85828399
## [153,]  0.13473571 -0.39059199  1.39781855  1.798155867  1.13834733
## [154,]  0.28255053  0.86260131 -0.31535901 -0.297926283 -0.12193769
## [155,] -0.51811312 -0.93662621 -0.97146956  0.151234178  0.22814148
## [156,]  0.20864312  2.55441226 -0.16955666  0.750114792 -0.47201686
## [157,]  1.03394258  1.59661452  0.04914686  0.001514024 -0.75208020
## [158,] -0.67824585  0.62091403  0.99686210  2.247316327 -0.19195352
## [159,]  1.64983769 -0.58752236  1.21556562  1.648435713 -0.12193769
## [160,]  0.59049809 -0.59647374  0.99686210  0.899834945 -0.75208020
## [161,] -0.78910697  1.33702448  0.04914686  0.450674485 -0.82209603
## [162,]  0.84917404  0.82679579  0.63235624  0.151234178  0.50820482
## [163,] -0.18552975  0.83574717  0.77815859  0.750114792  0.43818899
## [164,] -0.05003283  0.99687202 -0.06020490 -0.297926283  0.43818899
## [165,]  0.96003516  0.37922675 -0.24245783  0.750114792 -0.68206436
## [166,]  0.89844565  1.81144766 -0.38826018  0.899834945 -0.82209603
## [167,]  0.55354439  1.22065654  0.85105976  1.049555099  0.78826816
## [168,] -0.22248346  0.92526097 -0.24245783  0.001514024 -0.82209603
## [169,]  0.71367712  0.21810190  1.17911504  1.498715559  0.36817315
## [170,]  0.49195487  2.02628080  1.79877500  1.648435713  0.85828399
## [171,] -0.98619340  0.62091403 -0.16955666 -0.148206130 -0.26196936
## [172,] -0.28407297  0.04802567 -0.31535901  0.001514024 -0.96212770
## [173,]  1.42811545  0.15544223  0.41365272  0.151234178 -0.61204853
## [174,]  0.87380985  2.96617577  0.30430096  0.300954331 -0.33198519
## [175,]  0.49195487  1.40863553  0.41365272  1.049555099  0.15812565
## [176,]  0.33182214  1.73983662 -0.38826018  0.151234178  1.41841067
## [177,]  0.20864312  0.22705328  0.01269627  0.151234178  1.41841067
## [178,]  1.39116174  1.57871176  1.36136797  1.498715559 -0.26196936
##        Total_Phenols    Flavanoids Nonflavanoid_Phenols Proanthocyanins
##   [1,]   0.806721729  1.0319080692          -0.65770780      1.22143845
##   [2,]   0.567048088  0.7315652835          -0.81841060     -0.54318872
##   [3,]   0.806721729  1.2121137407          -0.49700500      2.12995937
##   [4,]   2.484437221  1.4623993954          -0.97911340      1.02925134
##   [5,]   0.806721729  0.6614853002           0.22615759      0.40027531
##   [6,]   1.557699140  1.3622851335          -0.17559941      0.66234866
##   [7,]   0.327374446  0.4912910549          -0.49700500      0.67982021
##   [8,]   0.487156874  0.4812796287          -0.41665360     -0.59560339
##   [9,]   0.806721729  0.9518166597          -0.57735640      0.67982021
##  [10,]   1.094330099  1.1220109049          -1.13981619      0.45268998
##  [11,]   1.046395371  1.2922051502          -1.13981619      1.37868246
##  [12,]  -0.151972837  0.4011882192          -0.81841060     -0.03651359
##  [13,]   0.487156874  0.7315652835          -0.57735640      0.38280376
##  [14,]   1.286069013  1.6626279192           0.54756319      2.12995937
##  [15,]   1.605633868  1.6125707883          -0.57735640      2.39203271
##  [16,]   0.886612943  0.8817366764          -0.49700500     -0.22870071
##  [17,]   0.806721729  1.1119994787          -0.25595080      0.66234866
##  [18,]   1.046395371  1.3722965597           0.30650899      0.22555975
##  [19,]   1.605633868  1.9029021478          -0.33630220      0.47016154
##  [20,]   0.646939302  1.0018737906          -1.54157319      0.12073042
##  [21,]   1.126286585  1.1420337573          -0.97911340      0.88947889
##  [22,]   0.183570261  0.3811653668          -0.89876200      0.67982021
##  [23,]   0.503135117  0.8517023978          -0.73805920      0.17314508
##  [24,]   0.295417961  0.3411196621          -0.81841060     -0.22870071
##  [25,]   0.375309174  0.5813938906          -0.65770780      0.12073042
##  [26,]   0.535091602  0.6514738740           0.86896878      0.57499088
##  [27,]   0.886612943  0.9117709549          -0.17559941     -0.24617226
##  [28,]   0.167592018  0.1609139906          -0.73805920     -0.42088782
##  [29,]   1.046395371  0.9418052335           0.06545479      0.29544598
##  [30,]   0.567048088  0.3010739573          -0.81841060      0.67982021
##  [31,]   1.126286585  1.2221251668          -0.57735640      1.37868246
##  [32,]   0.902591186  1.1620566097          -1.13981619      0.62740554
##  [33,]   0.199548504  0.6614853002           0.46721179      0.66234866
##  [34,]   1.046395371  0.7115424311           1.11002298     -0.42088782
##  [35,]   0.087700804  0.5013024811          -0.57735640     -0.08892826
##  [36,]   0.646939302  0.9518166597          -0.81841060      0.47016154
##  [37,]   0.487156874  0.6514738740          -0.17559941     -0.40341627
##  [38,]   0.247483232  0.4011882192          -0.57735640     -0.26364382
##  [39,]   0.167592018  0.6114281692          -0.65770780     -0.38594471
##  [40,]   1.126286585  1.0118852168          -1.30051899      0.85453577
##  [41,]   1.365960227  1.2621708716          -0.17559941      1.30879623
##  [42,]   0.247483232  0.6514738740          -0.73805920     -0.19375759
##  [43,]   1.525742654  1.5324793788          -1.54157319      0.19061664
##  [44,]   0.551069845  0.6014167430          -0.33630220      0.12073042
##  [45,]   1.126286585  0.9718395121          -0.65770780      0.76717799
##  [46,]   0.886612943  0.6214395954          -0.49700500     -0.59560339
##  [47,]   1.525742654  1.1420337573          -0.73805920      1.04672289
##  [48,]   1.286069013  1.3622851335          -1.22016759      0.95936511
##  [49,]   0.726830515  0.8917481025          -0.33630220      1.37868246
##  [50,]   0.934547672  1.5124565264          -0.33630220      0.85453577
##  [51,]   0.678895787  1.2421480192          -1.54157319      2.30467493
##  [52,]   0.247483232  0.9618280859          -1.13981619      1.22143845
##  [53,]   2.532371949  1.7126850502          -0.33630220      0.48763309
##  [54,]   1.126286585  0.7615995621           0.22615759      0.15567353
##  [55,]   0.487156874  0.8717252502          -1.22016759      0.05084419
##  [56,]   1.062373614  0.7515881359          -1.30051899      1.50098335
##  [57,]   1.445851440  0.9718395121          -0.81841060      0.76717799
##  [58,]   1.126286585  1.2021023145          -0.41665360      0.12073042
##  [59,]   1.765416296  1.6426050669          -1.38087039      0.78464955
##  [60,]  -0.503494178 -1.4609370523          -0.65770780     -2.04574255
##  [61,]  -0.391646479 -0.9403428904           2.15459116     -2.06321410
##  [62,]  -0.439581207 -0.6199772522           1.35107717     -1.69631142
##  [63,]  -0.311755265 -0.2395430570          -0.33630220     -1.50412430
##  [64,]   1.925198724  1.0719537740          -1.38087039      0.48763309
##  [65,]  -0.647298363 -0.2795887618           0.70826598     -0.97997762
##  [66,]   0.199548504  0.6214395954           0.06545479      0.85453577
##  [67,]   1.094330099  1.1520451835          -0.81841060      1.20396690
##  [68,]  -0.295777022 -0.0293031070          -0.73805920     -0.96250606
##  [69,]   0.375309174 -0.7301029403           1.51177997     -2.04574255
##  [70,]  -0.711211334 -0.7501257927          -1.78262739      1.58834113
##  [71,]  -1.909579543 -1.0104228737           0.06545479     -0.22870071
##  [72,]   1.046395371  0.8316795454          -1.22016759      0.48763309
##  [73,]  -0.663276606 -0.1894859260          -0.73805920     -0.97997762
##  [74,]   1.605633868  0.8617138240          -1.22016759      0.64487710
##  [75,]   1.733459810  0.1108568597          -1.86297878      0.10325886
##  [76,]  -1.094689161 -0.4597944332          -0.17559941     -0.77031895
##  [77,]  -0.551428907  0.0007311716          -0.97911340     -0.22870071
##  [78,]  -0.918928490 -0.7100800880           0.54756319     -1.11975007
##  [79,]  -0.631320120 -0.1794744999          -0.09524801      2.04260159
##  [80,]   0.854656458  0.5213253335           0.54756319      0.62740554
##  [81,]   0.199548504  0.2309939740          -0.49700500     -0.28111538
##  [82,]  -0.151972837  0.5013024811          -0.81841060      0.31291753
##  [83,]  -0.471537693 -0.4497830070           0.30650899     -0.33353004
##  [84,]  -1.030776190 -0.4397715808           1.99388837      0.05084419
##  [85,]  -0.151972837  0.1809368430          -1.13981619      1.32626779
##  [86,]  -0.151972837 -0.0893716641          -0.49700500     -0.22870071
##  [87,]  -0.823059034 -0.3396573189           0.54756319     -0.05398515
##  [88,]  -0.599363635 -0.4197487284           0.30650899     -0.43835938
##  [89,]  -0.551428907 -0.3396573189           0.94932018     -0.42088782
##  [90,]  -0.151972837 -0.4397715808           0.46721179     -0.36847316
##  [91,]  -1.110667404 -0.5298744165           1.27072578      0.08578730
##  [92,]  -1.350341045 -0.7801600713           1.11002298      0.06831575
##  [93,]  -1.462188745 -0.5699201213           1.75283417      0.05084419
##  [94,]   0.247483232  0.2209825478          -0.89876200      0.69729177
##  [95,]   1.158243070  0.2309939740          -1.54157319     -0.42088782
##  [96,]   0.327374446  0.2410054002          -0.33630220      2.95112251
##  [97,]  -1.110667404 -1.0404571523          -1.78262739     -0.05398515
##  [98,]   0.407265660  0.4712682025          -0.57735640      0.31291753
##  [99,]   1.957155209  1.7226964764          -0.97911340      0.62740554
## [100,]   0.886612943  0.9618280859           0.70826598      2.12995937
## [101,]  -0.104038109  0.1408911382          -0.81841060     -0.33353004
## [102,]  -1.350341045 -0.6700343832          -0.57735640     -0.42088782
## [103,]   0.423243903  0.0808225811          -0.17559941     -0.49077405
## [104,]   0.327374446 -0.3897144499           0.06545479     -0.29858693
## [105,]  -0.151972837 -0.1093945165          -0.33630220     -0.19375759
## [106,]  -0.982841462 -0.1894859260           2.39564536     -0.29858693
## [107,]  -1.030776190  0.0007311716           0.06545479      0.06831575
## [108,]  -1.462188745 -0.2695773356           0.94932018      0.06831575
## [109,]   0.103679047  0.0107425978           0.22615759      0.85453577
## [110,]   0.710852273  0.8917481025          -0.57735640      1.57086958
## [111,]   1.413894955  0.5513596121          -0.97911340      3.47526919
## [112,]   0.407265660  0.2410054002          -0.81841060     -0.64801805
## [113,]  -0.870993762  0.0007311716           1.91353697     -0.94503451
## [114,]   0.295417961 -0.0192916808           0.46721179     -0.26364382
## [115,]   0.423243903  0.2610282525           0.54756319     -0.96250606
## [116,]   0.263461475  0.1408911382           1.27072578      0.73223488
## [117,]  -0.503494178 -0.4297601546          -0.49700500     -0.10639981
## [118,]  -0.471537693  0.0607997287          -0.17559941      0.03337264
## [119,]  -1.062732675 -0.7801600713           0.54756319     -1.32940874
## [120,]  -0.471537693 -0.3897144499           0.06545479      0.48763309
## [121,]   0.966504157  0.7615995621          -0.33630220      0.41774687
## [122,]   1.413894955  3.0542161597           0.86896878      0.48763309
## [123,]  -0.151972837  0.1008454335           0.54756319      0.20808820
## [124,]   0.519113359  0.6214395954          -0.49700500      0.73223488
## [125,]   0.902591186  1.0018737906          -1.22016759      2.30467493
## [126,]   0.487156874  0.6214395954           0.06545479     -0.42088782
## [127,]   0.710852273  1.1220109049           0.22615759      0.31291753
## [128,]  -0.263820537  0.2109711216           1.75283417      0.29544598
## [129,]  -0.120016352  0.4212110716           0.30650899      0.54004776
## [130,]  -0.311755265 -0.2795887618           0.46721179     -0.42088782
## [131,]  -1.254471589 -0.7801600713          -1.22016759     -1.13722163
## [132,]  -1.590014687 -0.8101943499          -0.97911340     -1.32940874
## [133,]  -1.829688329 -0.9403428904          -0.73805920     -1.32940874
## [134,]  -0.950884976 -0.8302172023          -1.54157319     -1.31193719
## [135,]  -0.471537693 -1.4509256261           1.91353697     -0.59560339
## [136,]  -1.078710918 -1.3708342166           2.15459116     -1.13722163
## [137,]  -1.462188745 -1.5610513142           1.35107717     -1.38182341
## [138,]  -0.807080791 -1.4309027737           2.15459116     -0.85767673
## [139,]  -1.078710918 -1.5510398880           1.75283417     -1.24205096
## [140,]   0.039766076 -1.4309027737           1.35107717     -1.36435186
## [141,]  -1.206536860 -1.5310170356           1.35107717     -1.46918119
## [142,]  -1.430232259 -1.5310170356           0.06545479     -1.66136831
## [143,]  -1.190558618 -1.5109941832           1.11002298     -1.81861232
## [144,]  -0.471537693 -1.2306742499           0.86896878     -0.99744918
## [145,]  -1.462188745 -1.2506971023          -0.57735640     -0.78779050
## [146,]  -1.270449832 -1.4809599046           0.54756319     -0.50824560
## [147,]  -2.101318456 -1.6911998547           0.30650899     -1.59148209
## [148,]  -0.950884976 -1.3808456427           0.86896878     -1.27699407
## [149,]  -0.583385392 -1.2707199546           0.70826598     -0.59560339
## [150,]  -1.414254017 -0.6400001046          -0.17559941     -0.78779050
## [151,]  -1.430232259 -0.4597944332          -1.13981619     -0.59560339
## [152,]  -1.302406317 -0.6700343832          -0.97911340     -0.57813183
## [153,]  -0.151972837 -0.7501257927          -0.81841060     -0.05398515
## [154,]  -0.791102548 -1.2006399713           1.99388837      0.48763309
## [155,]  -1.302406317 -1.4509256261           1.35107717     -0.33353004
## [156,]  -0.886972005 -1.4008684951           1.99388837     -0.07145670
## [157,]  -0.791102548 -1.2006399713           0.94932018     -0.05398515
## [158,]  -0.631320120 -1.4509256261           2.15459116     -0.78779050
## [159,]   0.806721729 -0.7200915142           1.35107717      1.93777225
## [160,]   0.487156874 -0.9303314642           1.27072578      1.22143845
## [161,]   0.007809591 -1.1105371356           1.11002298     -0.96250606
## [162,]  -0.743167820 -1.4709484785           1.11002298     -1.38182341
## [163,]  -1.030776190 -1.4309027737           1.91353697     -1.10227851
## [164,]  -1.446210502 -1.3307885118           0.30650899     -1.13722163
## [165,]  -1.510123473 -1.3508113642           0.38686039     -0.97997762
## [166,]  -1.621971173 -1.5610513142           1.27072578     -0.77031895
## [167,]  -0.950884976 -1.1105371356           0.54756319     -0.22870071
## [168,]  -1.302406317 -1.3708342166           0.30650899     -1.08480696
## [169,]  -1.190558618 -1.1906285451           0.22615759     -0.08892826
## [170,]  -0.503494178 -1.0704914308          -0.73805920     -0.84020517
## [171,]  -1.669905901 -1.5410284618           0.30650899     -1.50412430
## [172,]  -1.446210502 -1.5210056094           0.94932018     -1.66136831
## [173,]  -0.982841462 -1.3307885118           0.62791458     -0.61307494
## [174,]  -0.982841462 -1.4208913475           1.27072578     -0.92756295
## [175,]  -0.791102548 -1.2807313808           0.54756319     -0.31605849
## [176,]  -1.126645647 -1.3407999380           0.54756319     -0.42088782
## [177,]  -1.030776190 -1.3508113642           1.35107717     -0.22870071
## [178,]  -0.391646479 -1.2707199546           1.59213137     -0.42088782
##        Color_Intensity         Hue       OD280      Proline cluster
##   [1,]     0.251008784  0.36115849  1.84272147  1.010159388       1
##   [2,]    -0.292496232  0.40490846  1.11031723  0.962526349       1
##   [3,]     0.268262912  0.31740852  0.78636920  1.391223700       1
##   [4,]     1.182731669 -0.42634104  1.18074072  2.328006800       1
##   [5,]    -0.318377423  0.36115849  0.44833648 -0.037767469       1
##   [6,]     0.729810822  0.40490846  0.33565890  2.232740722       1
##   [7,]     0.082781041  0.27365854  1.36384178  1.724654973       1
##   [8,]    -0.003489596  0.44865844  1.36384178  1.740532653       1
##   [9,]     0.061213382  0.53615839  0.33565890  0.946648670       1
##  [10,]     0.932546820  0.22990857  1.32158768  0.946648670       1
##  [11,]     0.298457635  1.27990794  0.78636920  2.423272878       1
##  [12,]    -0.025057256  0.92990815  0.29340481  1.692899614       1
##  [13,]     0.233754657  0.84240820  0.40608239  1.819921051       1
##  [14,]     0.147484019  1.27990794  0.16664254  1.280079943       1
##  [15,]     1.053325713  1.06115807  0.54692935  2.540767708       1
##  [16,]     0.967055075  1.41115786  0.37791299  1.788165692       1
##  [17,]     0.492566569  0.49240841  0.05396496  1.692899614       1
##  [18,]     0.665107844  0.75490825 -0.05871261  1.216569224       1
##  [19,]     1.570949537  1.19240799  0.29340481  2.963113987       1
##  [20,]     0.018078063  0.01115870  1.05397844  0.311541483       1
##  [21,]     0.255322316  0.57990836  1.54694284  0.105131647       1
##  [22,]    -0.240733849  0.31740852  1.27933359  0.073376288       1
##  [23,]    -0.542681081  0.66740831  1.95539905  0.914893310       1
##  [24,]    -0.486605166  0.57990836  1.43426526  0.851382592       1
##  [25,]    -0.663459973  0.71115828  1.70187450  0.311541483       1
##  [26,]    -0.637578782  0.75490825  0.82862329  0.263908444       1
##  [27,]    -0.111327893 -0.16384119  0.85679269  1.422979059       1
##  [28,]    -0.477978102  0.27365854  0.22298133  1.708777293       1
##  [29,]    -0.240733849  1.27990794  1.11031723  0.533828998       1
##  [30,]    -0.154463212  0.36115849  1.37792647  0.914893310       1
##  [31,]     0.276889975  1.01740810  0.13847314  1.708777293       1
##  [32,]     0.794513800  0.57990836  0.37791299  2.439150558       1
##  [33,]    -0.525426953  1.19240799  0.36382829  0.771994193       1
##  [34,]     0.147484019  1.27990794  0.54692935  1.550000497       1
##  [35,]    -0.370139806  0.62365833  0.36382829  1.105425466       1
##  [36,]     0.018078063  0.36115849  1.20891011  0.549706678       1
##  [37,]    -0.197598531  0.57990836  0.23706602  0.422685241       1
##  [38,]    -0.348572146  0.71115828 -0.14322079  1.137180826       1
##  [39,]    -0.585816399  0.97365812  0.11030375  0.867260271       1
##  [40,]     0.018078063 -0.29509111  1.29341829  0.041620929       1
##  [41,]     0.462371846 -0.03259127  1.08214784  0.152764686       1
##  [42,]    -0.335631551 -0.20759117  0.54692935  0.914893310       1
##  [43,]     0.160424615 -0.33884109  1.33567238  1.105425466       1
##  [44,]    -0.301123296 -0.60134093  0.54692935 -0.212421946       1
##  [45,]    -0.007803128 -0.33884109  1.03989375  0.438562920       1
##  [46,]     0.078467509 -0.38259106  1.01172435  1.057792427       1
##  [47,]    -0.068192574  0.36115849  1.16665602  1.010159388       1
##  [48,]     0.449431250 -0.20759117  1.01172435  0.756116514       1
##  [49,]     0.492566569  0.49240841  0.19481193  0.994281709       1
##  [50,]     1.657220175  0.71115828  0.68777632  1.629388895       1
##  [51,]     0.923919756  0.71115828  0.42016708  1.280079943       1
##  [52,]     0.233754657  1.23615797  1.06806314  1.645266575       1
##  [53,]     0.859216778  0.22990857  0.91313147  1.407101380       1
##  [54,]     0.535701888  0.75490825  0.44833648  1.994575527       1
##  [55,]     0.341592953 -0.16384119  0.82862329  0.994281709       1
##  [56,]     0.514134228  0.09865865  0.58918345  1.184813865       1
##  [57,]     0.570210143 -0.07634125  0.98355496  0.708483475       1
##  [58,]     0.406295932  0.49240841  0.32157420  1.661144254       1
##  [59,]     0.751378481 -0.29509111  0.36382829  1.708777293       1
##  [60,]    -1.340684477  0.40490846 -1.11506488 -0.720507695       3
##  [61,]    -0.771298270  1.27990794 -1.32633534 -0.212421946       3
##  [62,]     0.298457635  0.09865865 -1.43901291 -0.942795210       2
##  [63,]    -0.542681081  1.19240799 -0.21364428 -0.371198742       3
##  [64,]    -0.262301509  1.14865802  0.36382829 -1.038061288       3
##  [65,]    -0.909331290  2.15490741 -0.53759231 -1.244471124       3
##  [66,]    -0.197598531  1.01740810 -0.43899943 -0.218773018       3
##  [67,]     0.104348700  0.71115828  0.80045390 -0.777667342       3
##  [68,]    -0.163090276  0.71115828  1.22299481 -0.752263054       3
##  [69,]    -0.814433589  0.27365854 -0.96013322  0.009865569       3
##  [70,]    -0.952466609  1.41115786  0.64552223 -0.091751580       3
##  [71,]    -0.866195971 -0.22509116 -1.11506488  0.390929881       3
##  [72,]    -0.723849419  1.76115765  0.77228450 -1.069816648       3
##  [73,]    -0.568562272  0.09865865  0.23706602 -0.872933420       3
##  [74,]    -0.736790015  1.54240778  1.25116420  0.756116514       1
##  [75,]    -0.797179461  0.14240862  0.73003041  0.441738456       3
##  [76,]    -0.542681081  1.19240799 -0.66435458 -1.012657001       3
##  [77,]    -0.197598531  1.01740810 -0.18547489 -1.126976294       3
##  [78,]    -1.038737246  0.01115870 -0.12913610 -0.784018414       3
##  [79,]    -0.715222356  0.44865844 -0.42491473  0.009865569       3
##  [80,]    -1.073245501  1.01740810  0.73003041 -0.901513243       3
##  [81,]    -1.103440224  1.84865760  0.71594572 -1.488987391       3
##  [82,]    -0.499545762  0.88615818  0.74411511 -0.104453724       3
##  [83,]    -1.232846180  1.54240778  0.15255784 -0.371198742       3
##  [84,]    -0.111327893 -0.51384098 -0.84745564 -0.736385375       2
##  [85,]    -0.866195971 -0.73259085  0.65960693 -0.720507695       3
##  [86,]    -1.051677842  1.19240799  0.77228450 -0.942795210       3
##  [87,]    -1.125007884  1.62990773 -0.49533822 -0.799896093       3
##  [88,]    -1.060304905  1.76115765  0.84270799 -0.587135186       3
##  [89,]    -0.974034268  0.18615860  0.19481193 -0.212421946       3
##  [90,]    -1.431268647  0.49240841  0.84270799 -0.387076422       3
##  [91,]    -1.146575543  0.53615839 -0.48125352 -0.847529132       3
##  [92,]    -0.628951718  0.40490846  0.05396496 -0.942795210       3
##  [93,]    -0.866195971  0.01115870 -0.77703216 -0.799896093       3
##  [94,]    -1.254413840  0.84240820  0.96947026 -1.450880959       3
##  [95,]    -0.779925334  0.88615818  0.49059057 -1.276226483       3
##  [96,]    -1.060304905  0.88615818  0.02579557  0.603690789       1
##  [97,]    -1.103440224 -0.03259127 -0.49533822 -0.387076422       3
##  [98,]    -0.930898949  1.19240799  0.18072723 -1.012657001       3
##  [99,]    -0.240733849  0.36115849  0.22298133 -0.275932664       3
## [100,]    -1.189710862  2.02365749  0.30748951 -1.082518791       3
## [101,]    -0.758357674  1.36740789  0.49059057 -0.117155868       3
## [102,]    -1.125007884  0.36115849  0.22298133 -0.587135186       3
## [103,]    -0.974034268 -0.68884088  1.08214784 -0.980901641       3
## [104,]    -1.293235627 -0.07634125 -0.24181367 -1.053938968       3
## [105,]    -0.913644822  0.36115849  1.34975708 -0.237826233       3
## [106,]    -1.017169587 -0.42634104  0.96947026 -1.371492561       3
## [107,]    -0.715222356  0.18615860  0.78636920 -0.752263054       3
## [108,]    -0.758357674 -0.33884109 -0.26998307 -0.822124845       3
## [109,]    -1.017169587 -0.42634104  0.57509875 -1.381019169       3
## [110,]    -1.038737246  0.01115870  0.91313147 -0.212421946       3
## [111,]    -0.930898949 -0.90759075  0.27932011 -0.587135186       3
## [112,]    -1.319116818 -0.25134114  0.23706602 -1.339737202       3
## [113,]    -0.542681081  1.19240799 -0.15730549 -0.444236069       3
## [114,]    -0.853255375  0.62365833 -0.42491473 -0.993603785       3
## [115,]    -0.930898949 -0.12009122  0.81453860 -1.149205046       3
## [116,]    -1.362252137  3.29240673  0.36382829 -1.079343255       3
## [117,]    -1.340684477 -0.03259127  1.01172435 -0.799896093       3
## [118,]    -1.293235627  0.44865844  0.49059057 -1.276226483       3
## [119,]    -0.715222356 -1.12634062 -0.69252397 -1.190487013       2
## [120,]    -1.629691113 -0.12009122  0.61735284 -0.580784114       3
## [121,]    -0.779925334 -0.68884088  1.09623253 -0.387076422       3
## [122,]     0.406295932 -0.12009122  1.51877344 -0.895162171       1
## [123,]    -1.284608563 -0.16384119  0.71594572 -1.212715765       3
## [124,]    -1.060304905 -0.99509069  0.68777632 -1.165082726       3
## [125,]    -0.974034268 -0.90759075  1.44834996 -1.165082726       3
## [126,]    -0.991288395 -0.42634104  0.94130087 -1.171433797       3
## [127,]    -0.482291634 -1.17009059  0.32157420 -1.253997732       3
## [128,]    -0.887763630  0.05490867 -0.24181367 -0.891986635       3
## [129,]    -1.267354435 -0.29509111  0.23706602 -1.285753091       3
## [130,]    -1.060304905 -0.73259085 -0.05871261 -0.529975539       3
## [131,]    -0.413275124 -0.86384077 -1.86155382 -0.371198742       2
## [132,]     0.147484019 -0.95134072 -1.67845276 -0.688752336       2
## [133,]     0.276889975 -1.30134051 -1.76296094 -0.593486258       2
## [134,]    -0.025057256 -0.77634083 -1.86155382 -0.466464820       2
## [135,]     0.169051679 -0.90759075 -1.55169049 -0.307688024       2
## [136,]     0.880784438 -0.99509069 -1.45309761 -0.164788907       2
## [137,]    -0.521113421 -0.90759075 -1.88972321 -0.085400508       2
## [138,]    -0.025057256 -0.60134093 -1.29816594 -0.736385375       2
## [139,]     0.276889975 -0.64509090 -1.11506488 -0.529975539       2
## [140,]    -0.059565511 -0.29509111 -0.65026988 -0.498220180       2
## [141,]    -0.197598531 -0.82009080 -0.42491473 -0.466464820       2
## [142,]     0.233754657 -1.12634062 -0.19955958  0.105131647       2
## [143,]    -0.305436828 -0.29509111 -0.77703216 -0.720507695       2
## [144,]    -0.283869168 -0.20759117 -0.79111685 -0.625241617       2
## [145,]     1.359586476 -1.34509048 -0.86154034  0.343296842       2
## [146,]    -0.456410443 -1.56384035 -1.31225064  0.263908444       2
## [147,]    -0.068192574 -1.65134030 -1.80521503 -1.053938968       2
## [148,]     1.118028691 -1.82634020 -1.05872609 -0.387076422       2
## [149,]     1.450170645 -1.78259022 -1.39675882 -0.307688024       2
## [150,]     1.872896769 -1.69509027 -1.80521503 -0.625241617       2
## [151,]     1.527814219 -1.60759033 -1.84746912 -0.784018414       2
## [152,]     2.476791231 -2.08884004 -1.60802927 -0.847529132       2
## [153,]     0.880784438 -1.52009038 -1.80521503 -1.022183609       2
## [154,]     2.356012338 -1.73884025 -1.55169049 -0.228299625       2
## [155,]     1.096461031 -1.65134030 -1.49535170 -0.339443383       2
## [156,]     1.225866988 -1.56384035 -1.59394458 -0.069522829       2
## [157,]     1.704669026 -1.69509027 -1.36858943 -0.847529132       2
## [158,]     1.053325713 -1.25759054 -1.24182715  0.422685241       2
## [159,]     3.425768243 -1.69509027 -0.91787912 -0.275932664       2
## [160,]     2.886576759 -1.69509027 -1.17140367 -0.402954102       2
## [161,]     1.118028691 -1.73884025 -1.45309761 -0.720507695       2
## [162,]     0.354533549  0.01115870 -1.11506488 -0.212421946       2
## [163,]     0.225127593 -0.38259106 -0.70660867 -0.561730898       2
## [164,]     0.095721637 -1.21384056 -1.21365776 -0.228299625       2
## [165,]     1.950540342 -1.12634062 -1.31225064 -0.418831781       2
## [166,]     0.673734908 -0.77634083 -1.21365776 -0.720507695       2
## [167,]     2.425028848 -0.47009101 -1.48126700 -0.164788907       2
## [168,]     2.243860510 -1.03884067 -1.21365776 -0.196544266       2
## [169,]     1.553695410 -0.95134072 -1.14323428  0.009865569       2
## [170,]     1.484678900 -1.25759054 -0.97421791 -0.371198742       2
## [171,]     0.190619338 -1.30134051 -1.10098018 -0.752263054       2
## [172,]     2.088572931 -1.69509027 -1.38267412 -0.879284492       2
## [173,]     2.002302725 -1.47634041 -1.26999655 -0.275932664       2
## [174,]     1.139596350 -1.38884046 -1.22774246 -0.021889790       2
## [175,]     0.967055075 -1.12634062 -1.48126700  0.009865569       2
## [176,]     2.217979318 -1.60759033 -1.48126700  0.279786124       2
## [177,]     1.829761450 -1.56384035 -1.39675882  0.295663803       2
## [178,]     1.786626131 -1.52009038 -1.42492821 -0.593486258       2

Paso 8. Graficar los clusters

fviz_cluster(segmentos, data = df)

Paso 9. Optimizar la cantidad de grupos

La cantidad óptima de grupos corresponde al punto más alto de la siguiente gráfica

set.seed(123)
optimizacion <- clusGap(df, FUN=kmeans, nstart = 1, K.max = 10)
plot(optimizacion, xlab='Número de clusters k')

Paso 11. Comparación entre segmentos

promedio <- aggregate(asignacion, by=list(segmentos$cluster), FUN=mean)
promedio
##   Group.1    Alcohol Malic_Acid        Ash Ash_Alcanity   Magnesium
## 1       1  0.8328826 -0.3029551  0.3636801   -0.6084749  0.57596208
## 2       2  0.1644436  0.8690954  0.1863726    0.5228924 -0.07526047
## 3       3 -0.9234669 -0.3929331 -0.4931257    0.1701220 -0.49032869
##   Total_Phenols  Flavanoids Nonflavanoid_Phenols Proanthocyanins
## 1    0.88274724  0.97506900          -0.56050853      0.57865427
## 2   -0.97657548 -1.21182921           0.72402116     -0.77751312
## 3   -0.07576891  0.02075402          -0.03343924      0.05810161
##   Color_Intensity        Hue      OD280    Proline cluster
## 1       0.1705823  0.4726504  0.7770551  1.1220202       1
## 2       0.9388902 -1.1615122 -1.2887761 -0.4059428       2
## 3      -0.8993770  0.4605046  0.2700025 -0.7517257       3

Conclusión

La segmentación o clusters es un algoritmo útil para las empresas que desean clasificar sus clientes y dirigir campañas de MKT más enfocadas y especializdas.

LS0tCnRpdGxlOiAiV2luZSAoQ2x1c3RlcikgU2VnbWVudGFjacOzbiIKYXV0aG9yOiAiR2VuYXJvIFJvZHLDrWd1ZXogQWxjw6FudGFyYSAtIEEwMDgzMzE3MiIKZGF0ZTogIjIwMjQtMDItMTkiCm91dHB1dDogCiAgaHRtbF9kb2N1bWVudDoKICAgIHRv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