The Elegance of Association Analysis
2020-04-10 · 2 min read
Originally published on Medium / Analytics Vidhya
In a world obsessed with deep learning, I have a soft spot for techniques that produce output a human can read. Association analysis is one of those — feed it transaction data, and it tells you "people who buy X also buy Y, 73% of the time." No hidden layers. No gradient descent. Just patterns, exposed.
The question it answers
"If a customer does X, what else are they likely to do?"
Simple question. Surprisingly powerful answers.
The three metrics that matter
- Support — How often does this combination appear? Filters out noise.
- Confidence — Given A happened, how often does B follow? The conditional probability.
- Lift — Is this association real, or just base-rate coincidence? Lift > 1 means something's actually there.
from mlxtend.frequent_patterns import apriori, association_rules
frequent_items = apriori(basket_df, min_support=0.05, use_colnames=True)
rules = association_rules(frequent_items, metric="confidence", min_threshold=0.6)
rules.sort_values('lift', ascending=False)
Why this matters beyond shopping carts
I keep thinking about where else this applies:
- Incident correlation — Which service failures tend to co-occur? If service A goes down, should I preemptively check service B?
- Security patterns — Which attack vectors cluster together?
- User behavior — What navigation paths predict conversion?
These are the same questions I deal with at AWS, just framed differently.
The beauty of it
The Apriori property makes the whole thing computationally tractable: if an itemset is infrequent, all its supersets must be too. One insight, exponential pruning.
And unlike a neural network where you're staring at a black box hoping it learned something useful — association rules give you output that a domain expert can validate in seconds. There's something deeply satisfying about that transparency.
In distributed systems, I've learned to value the same thing: systems you can reason about are systems you can trust.