Question: Exercise 1 . 2 : Write the Matlab script for k - means clustering Import the dataset Mall _ Customers.csv , using readtable function. Convert

Exercise 1.2: Write the Matlab script for k-means clustering
Import the dataset Mall_Customers.csv, using readtable function.
Convert columns 4(Annual income) and 5(Spending score) of the table to X, using table2array
function.
Plot Spending score against Annual income.
Set the number of clusters (k) from 1 to 10, use [idx,C, sumd]= kmeans(X,k)(where sumd
returns the within-cluster sums of point-to-centroid distances or the WCSS (within-cluster 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!