Association Rules: Support, Confidence and Lift

medium
Unit 21 · Market Basket0/2 to milestone

For a rule A -> B over a list of transactions (sets of items):

  • support = fraction of transactions containing both A and B
  • confidence = support(A ∪ B) / support(A)
  • lift = confidence / support(B)
  • conviction = (1 - support(B)) / (1 - confidence) (return inf when confidence is 1)

A and B are sets of items. Implement rule_metrics(transactions, A, B) returning a dict with those four keys.

#market-basket#association-rules2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Association Rules: Support, Confidence and Lift · TechGradify