Question: Exercise 1 . 2 : Write the Matlab script for k - means clustering Import the dataset Mall _ Customers.csv , using readtable function. Convert
Exercise : Write the Matlab script for kmeans clustering
Import the dataset MallCustomers.csv using readtable function.
Convert columns Annual income and Spending score of the table to X using tablearray
function.
Plot Spending score against Annual income.
Set the number of clusters k from to use idxC sumd kmeansXkwhere sumd
returns the withincluster sums of pointtocentroid distances or the WCSS withincluster sum of
squares and the Elbow method to find the optimal number of clusters.
Use the k chosen in the last step to perform the kmeans clustering and use gscatter function to
visualise the clusters. You can add the centroids of the clusters to the plot.
Generate the silhouette plot to evaluate the clustering, using silhouette function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
