Session Ready
Exercise

Pruning with lift

Once again, you report back to the novelty gift store manager. This time, you tell her that you identified no rules when you used a higher support threshold for the Apriori algorithm and only two rules when you used a lower threshold. She commends you for the good work, but asks you to consider using another metric to reduce the two rules to one.

You remember that lift had a simple interpretation: values greater than 1 indicate that items co-occur more than we would expect if they were independently distributed across transactions. You decide to use lift, since that message will be simple to convey. Note that pandas is available as pd and the one-hot encoded transaction data is available as onehot. Additionally, apriori has been imported from mlxtend.

Instructions
100 XP
  • Import the association_rules function from mlxtend.
  • Compute the frequent itemsets using a support of 0.001 and a maximum itemset length of 2.
  • Complete the statement to retain rules with a lift of at least 1.0.
  • Print the DataFrame of rules.