Statistics lab charts
NumLM logo
NumLM
LEARN · SIMULATE · VERIFY

From probability to LLMs — a self-paced learning platform that teaches the principles properly

Sign in
Learn
ToolsBlog
Help
Home
This page in other languages:한국어 원문
English

Association Rules and Anomaly Detection

Master it step by step with milestone learning
association rules
market basket analysis
support
confidence
lift
apriori
anomaly detection
isolation forest
What you will be able to do after this lesson
Foundations
  • • Explain that association rule learning and anomaly detection are unsupervised learning tasks that find structure without labels
  • • Use the market-basket analogy to explain intuitively what support, confidence, and lift each measure
  • • Explain why fraud, equipment faults, and network intrusions are the classic applications of anomaly detection (rare but costly events)
Deeper dive
  • • Compute support, confidence, and lift by hand from a small transaction table and interpret lift >1 / =1 / <1
  • • Explain the pruning principle of Apriori ("do not count supersets of an infrequent set")
  • • Flag anomalies with the z-score (|z| > 3) and IQR (1.5×IQR) rules and explain the difference in robustness between the two methods
In practice
  • • Understand rule explosion as a multiple-testing problem and explain why reproducibility checks are necessary
  • • Point out the accuracy trap in rare-class problems and design an evaluation based on precision, recall, and the PR curve
  • • Apply the design logic of semi-supervised anomaly detection (novelty detection), which trains on normal data only, to a practical scenario
At a glance

Association rule learning is an unsupervised learning task that finds patterns of items appearing together — such as "customers who buy A also buy B" — using support, confidence, and lift, while anomaly detection is an unsupervised learning task that finds observations that deviate sharply from the normal pattern.

Learning roadmap

Click a step to view its lesson content

Foundations
Definition and core principles
about 15 min
Click
Deeper dive
Derivations and worked examples
about 35 min
Click
In practice
Real cases and advanced applications
about 50 min

Progress (completed steps)

0%

BasicFinding Hidden Patterns and Odd Points Without Labels

Basic: Finding Hidden Patterns and Odd Points Without Labels

Difficulty 2/5
about 15 min

Association rule learning and anomaly detection are unsupervised learning tasks: they uncover the structure hidden in data without any answer labels. Association rule learning looks for "combinations of items that frequently appear together" (the classic example is market basket analysis), while anomaly detection does the opposite — it looks for "the few observations that deviate sharply from the normal pattern of the majority." One targets the common patterns of the many; the other targets the exceptions of the few. In that sense they are mirror images of each other.

Key points
  • Both are unsupervised learning tasks that use only the structure of the data, with no answer labels — association rules find "patterns that appear together," anomaly detection finds "exceptions that break the pattern"
  • The three core metrics of association rules: support (how often the combination appears overall), confidence (the share of people who bought A that also bought B), and lift (whether A actually raises the probability of buying B)
  • The Apriori algorithm finds frequent itemsets by using the property that "subsets of a frequent combination must also be frequent" to cut hopeless candidates in advance (pruning)
  • Typical uses of anomaly detection: credit card fraud detection, factory equipment fault detection, network intrusion detection — all target events that are "rare but expensive to miss"
A simple example

Observing 10 convenience-store receipts (an educational scenario): Looking through 10 receipts, you find that 5 of them include bread, and 4 of those 5 also include milk. The confidence of the rule "bread → milk" is 4/5 = 80%. But milk is a popular item to begin with — it appears on 5 of the 10 receipts (50%). Knowing that bread was bought raised the probability of milk from 50% to 80%, so this rule shows an association beyond chance (lift 0.8/0.5 = 1.6). Now suppose you look at the payment amounts at the same store. Most fall between ₩3,000 and ₩20,000 — and then one day a single ₩900,000 charge appears at 3 a.m. That observation, far outside the normal pattern of the majority, is an anomaly candidate. Card issuers automatically flag transactions like this and call to verify them.

Left: counting the support (0.6) and confidence (0.75) of the rule "bread → milk" across 5 baskets. Right: an observation far from the normal cluster is flagged as an anomaly.Left: counting the support (0.6) and confidence (0.75) of the rule "bread → milk" across 5 baskets. Right: an observation far from the normal cluster is flagged as an anomaly.
Check your understanding

Answer: Because both tasks find structure using only the frequencies and distribution of the data itself, without answer labels (such as "this combination is a good rule" or "this transaction is fraud"). Association rules are built from how often items appear together, and anomaly detection uses the normal pattern formed by the majority of the data as a baseline to find exceptions.

Answer: If milk is a popular item found in almost every basket, then attaching "→ milk" to any item — regardless of bread — will produce a high confidence. Lift measures "did knowing that bread was bought actually raise the probability of buying milk above its baseline?" Only when lift is greater than 1 can you say the association goes beyond chance.

Answer: They are fields like fraud, equipment failure, and network intrusion, where "normal cases overwhelmingly outnumber abnormal ones, abnormal cases are very rare, but missing one is costly." Because it is hard to collect enough labeled abnormal cases, an unsupervised approach that measures deviation from the normal pattern without labels is the natural fit.

Back to the machine learning theory page