clustering for segments we will be using the -means clustering algorithm for finding out clusters (or segments in our datait is one of the simplest clustering algorithms that we can employ and hence it is widely used in practice we will give you brief primer of the algorithm before we go on to using the samefor finding segments in our data  -means clustering the -means clustering belongs to the partition based\centroid based clustering family of algorithms the steps that happen in the -means algorithm for partitioning the data are as given follows the algorithm starts with random point initializations of the required number of centers the "kin -means stands for the number of clusters in the next stepeach of the data point is assigned to the center closest to it the distance metric used in -means clustering is normal euclidian distance once the data points are assignedthe centers are recalculated by averaging the dimensions of the points belonging to the cluster the process is repeated with new centers until we reach point where the assignments become stable in this casethe algorithm terminates we will adapt the code given in the scikit-learn documentation at stable/auto_examples/cluster/plot_kmeans_silhouette_analysis html and use the silhouette score for finding out the optimal number of clusters during our clustering process we leave it as an exercise for you to adapt the code and create the visualization in figure - you are encouraged to modify the code in the documentation to not only build the visualizationbut also to capture the centers and the silhouette score of each cluster in dictionaryas we will need to refer to those for performing our analysis of the customer segments obtained of coursein case you find it overwhelmingyou can always refer to the detailed code snippet in the customer segmentation ipynb notebook