Practical task 5

Preparing the data

# Loading required libraries
library(readr)
library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
# Loading the dataset
data <- read.csv("~/Documents/DATA ANALYTICS/Ice.csv")

# Checking the structure of the data
str(data)
## 'data.frame':    11 obs. of  14 variables:
##  $ tastes_excellent: num  0.206 0.412 0.48 0.118 0 ...
##  $ look_good       : num  0.1176 0.3431 0.2941 0.1373 0.0196 ...
##  $ satisfies_hunger: num  0.1275 0.2941 0.2941 0.0784 0.0098 ...
##  $ satisfies_thirst: num  0.0098 0.0196 0.049 0 0 ...
##  $ refreshing      : num  0.0294 0.0686 0.1078 0.0294 0.0098 ...
##  $ for_everyday    : num  0.0588 0.2255 0.1961 0.049 0.0098 ...
##  $ for_special     : num  0.108 0.265 0.294 0.275 0 ...
##  $ for_adults      : num  0.1176 0.3922 0.402 0.2843 0.0196 ...
##  $ favorite        : num  0.0686 0.2451 0.2647 0.0392 0.0098 ...
##  $ different       : num  0.0686 0.1863 0.0882 0.0882 0.0392 ...
##  $ cool            : num  0.0784 0.2451 0.098 0.0196 0.0196 ...
##  $ never_eat       : num  0.0784 0.0294 0.0294 0.0882 0.1176 ...
##  $ fun             : num  0.0784 0.0882 0.1176 0.049 0.0588 ...
##  $ expensive       : num  0.0882 0.549 0.3529 0.1961 0.0196 ...
# Performing necessary preprocessing: For k-means clustering, scaling is usually performed to normalize the variables

# Scaling the data
scaled_data <- scale(data)

Determining the optimal number of clusters using Elbow method or Silhouette method

From the plot, we can identify the ‘elbow’ point where the decrease in WSS slows down. From that, we can see that the ideal number of clusters is 3.

Performing k-means clustering with the determined number of clusters

Identifying which properties characterize the prototypes

To identify the properties that characterize the prototypes within each cluster, we can analyze the original data in relation to the cluster assignments. This involves comparing the average values of different properties for each cluster.

##   Cluster look_good satisfies_hunger satisfies_thirst refreshing for_everyday
## 1       1 0.1078431       0.05065359       0.03758170 0.06699346    0.0751634
## 2       2 0.3186275       0.29411765       0.03431373 0.08823529    0.2107843
## 3       3 0.1960784       0.06862745       0.37581699 0.35947712    0.2450980
##   for_special for_adults   favorite different       cool  never_eat       fun
## 1  0.08006536 0.09640523 0.06372549 0.0620915 0.07843137 0.09967320 0.1029412
## 2  0.27941176 0.39705882 0.25490196 0.1372549 0.17156863 0.02941176 0.1029412
## 3  0.06862745 0.01960784 0.20261438 0.1241830 0.13071895 0.01307190 0.4117647
##    expensive
## 1 0.08496732
## 2 0.45098039
## 3 0.03921569

These average values illustrate the characteristics of each cluster, indicating which properties are more prevalent within each group.

Cluster 1 seems to have higher average ratings in categories such as ‘refreshing’, ‘for_everyday’, ‘fun’, and ‘favorite’, suggesting that this cluster tends to prefer ice cream that is refreshing, suitable for everyday consumption, fun, and a favorite among the group. The ‘expensive’ attribute is relatively lower in this cluster.

Cluster 2 has lower average ratings across most categories compared to the other clusters. This cluster seems to have lower overall ratings in various attributes, indicating a less favorable view of the ice creams evaluated.

Cluster 3 has higher average ratings for ‘look_good’, ‘satisfies_hunger’, ‘for_special’, ‘for_adults’, and ‘expensive’, indicating a preference for ice creams that look good, satisfy hunger, are for special occasions or adults, and might be considered more expensive.

By analyzing these averages, we can gain insights into the types of ice creams that each cluster prefers based on the properties they find important or appealing. The higher average values suggest the properties that are more characterizing or prevalent within each cluster.