cluster descriptions on the basis of eyeballing the cluster centerswe can figure out that we have good difference in the customer value in the segments as defined in terms of recencyamount and frequency to further drill down on this point and find out the quality of these differencewe can label our data with the corresponding cluster label and then visualize these differences we will do this visualization for probably one of the most important customer value indicatorsthe total dollar value sales to arrive at such distinction based summary computationswe will first label each data row in our customer summary dataframe with the corresponding label as returned by our clustering algorithm note that you have to modify the code you are using if you want to try different configuration of let' say two or four clusters we will have to make changes so that we capture the labels for each different cluster configuration we encourage you to try other cluster configurations to see if you get even better segmentsthe following code will extract the clustering label and attach it with our customer summary dataframe labels cluster_centers[ ]['labels'customer_history_df['num_cluster _labels'labels labels cluster_centers[ ]['labels'customer_history_df['num_cluster _labels'labels once we have the labels assigned to each of the customersour task is simple now we want to find out how the summary of customer in each group is varying if we can visualize that information we will able to find out the differences in the clusters of customers and we can modify our strategy on the basis of those differences we have used lot of matplotlib and seaborn so farwe will be using plotly in this section for creating some interactive plots that you can play around with in your jupyter notebook##note while plotly provides excellent interactive visualizations in jupyter notebooksyou might come across some notebook rendering issues that come up as popups when you open the notebook to fix this problemupgrade your nbformat library by running the conda update nbformat command and re-open the notebook the problem should disappear the following code leverages plotly and will take the cluster labels we got for the configuration of five clusters and create boxplots that will show how the medianminimummaximumhighestand lowest values are varying in the five groups note that we want to avoid the extremely high outlier values of each groupas they will interfere in making good observation (due to noisearound the central tendencies of each cluster so we will restrict the data such that only data points which are less than th percentile of the cluster is used this will give us good information about the majority of the users in that cluster segment the following code will help us create this plot for the total sales value import plotly as py import plotly graph_objs as go py offline init_notebook_mode(x_data ['cluster ','cluster ','cluster ','cluster ''cluster 'cutoff_quantile field_to_plot 'amounty =customer_history_df[customer_history_df['num_cluster _labels']== ][field_to_plotvalues [ <np percentile( cutoff_quantile) =customer_history_df[customer_history_df['num_cluster _labels']== ][field_to_plotvalues