Heatmaps with lift
The founder likes the heatmap you've produced for her streaming service. After discussing the project further, however, you decide that that it is important to examine other metrics before making a final decision on which movies to license. In particular, the founder suggests that you select a metric that tells you whether the support values are higher than we would expect given the films' individual support values.
You recall that lift does this well and decide to use it as a metric. You also remember that lift has an important threshold at 1.0 and decide that it is important to replace the colorbar with annotations, so you can determine whether a value is greater than 1.0. Note that the rules from the previous exercise are available to you as rules
.
Diese Übung ist Teil des Kurses
Market Basket Analysis in Python
Anleitung zur Übung
- Import
seaborn
under its standard alias. - Transform the
DataFrame
containing rules into a matrix using the lift metric. - Generate a heatmap with annotations on and the colorbar off.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Import seaborn under its standard alias
____
# Transform the DataFrame of rules into a matrix using the lift metric
pivot = rules.____(index = 'consequents',
columns = 'antecedents', values= '____')
# Generate a heatmap with annotations on and the colorbar off
sns.heatmap(pivot, annot = ____, ____)
plt.yticks(rotation=0)
plt.xticks(rotation=90)
plt.show()