Last answered:

28 Jul 2022

Posted on:

26 Jul 2022


How do the segments (names) get created?

I don't quite understand how the segments and their names are getting into here. When naming the "labels" in the pie chart, how does Python know which value is tied with which segment name? I guess I don't understand why we saved the models as "pickles" and used them here in the first place. Thanks!

1 answers ( 0 marked as helpful)
Posted on:

28 Jul 2022


Hi Christine,
thanks for reaching out! To answer your question - we save the k-means prediction algorithm which we trained with the segmentation data set. It recognizes the four different clusters, that is when tested on a new data set it will assign each entry one of the four segments - 0, 1, 2 or 3. That's what we use for predicting on the purchase data in this purchase analytics part of the course. So, we're not training a new model, but using the already trained model on new unseen data.
The labels or names of the segment we add manually to the pie chart labels as list:

labels = ['Standard', 'Career focused', 'Fewer Opportunities', 'Well-off']

We know that segment 0 corresponds to the standard segment, 1 to the career focused and so on. So we add the labels at this step, however the segments themselves correspond to our segmentation analysis from the previous part of the course.
Hope this helps!

365 Eli

Submit an answer