Semi-supervised Apriori Algorithm

Machine Learning
Introduced by
Extended from Agrawal & Srikant (1994); constrained variants developed by Liu, Hsu & Ma (1999) and others
Year
1999–2005
Type
Constrained association rule mining algorithm
Family
Machine learning

What does it do?

Semi-supervised Apriori is a descriptive name for variants of the Apriori frequent-itemset miner that add background knowledge to the search.

Such knowledge may take the form of must-link or cannot-link constraints between items, or item-specific minimum support thresholds. The base procedure is Agrawal & Srikant (1994), and the use of multiple minimum supports for items with unequal frequencies is developed by Liu, Hsu & Ma (1999). The label names a family of methods rather than a single published algorithm, so implementations can differ in how they apply constraints.

The intuition behind the method

Standard Apriori enumerates every itemset that meets one global minimum support, which on real data can produce a very large number of rules, many of them trivial or redundant. A constrained variant accepts domain knowledge before the search starts: for example, pairs of items that should be considered together, pairs that should never co-occur, or lower support thresholds for rare items that matter to the analysis. Cannot-link pairs can be excluded from candidates before support counting, while the remaining constraints shape which rules are reported, so the search concentrates on rules that fit the stated knowledge. The quality of the output therefore depends on how well that knowledge is specified.

History

Agrawal and Srikant (1994) introduced the Apriori algorithm for mining association rules from transaction databases. Liu, Hsu and Ma (1999) addressed the limitation of a single minimum support by allowing multiple minimum supports so that rare items can be mined without excessive combinatorial growth. Constraint-based variants, including must-link and cannot-link forms, are not attributed to a single originator here; they are best treated as a family of methods rather than one named algorithm.

When to use it

Choose this family when your data are transactional or basket-style categorical records, and you have concrete domain knowledge that should shape which patterns are reported: items that must co-occur, combinations that are impossible or irrelevant, or rare items that need lower thresholds. It is most useful when the item space is large and unconstrained Apriori returns more rules than can be reviewed. Do not use it when the attributes are numerical and cannot be sensibly discretised, because Apriori needs categorical items. Do not use it when no domain knowledge is available; plain Apriori or FP-Growth is then the simpler choice. It is also a weak choice when the transaction database is so sparse that support counts are unstable.

Limitations and considerations

  • Candidate generation is still Apriori's level-wise join, so the search can grow rapidly on high-dimensional item spaces even when constraints prune it.
  • Results depend on the constraints supplied: an incorrect cannot-link pair or an over-restrictive item-specific threshold removes rules that may be genuinely interesting.
  • Numerical attributes must be discretised into categorical items first, which adds a preprocessing decision that changes which itemsets are frequent.
  • Constraint handling is not part of the basic Apriori procedure, so it usually has to be implemented on top of a base Apriori implementation.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Background constraints focus the output on rules consistent with domain knowledge, which reduces the number of rules a reviewer must inspect.
  • Cannot-link pairs are excluded before support counting, so candidates containing them never reach the database scan and the candidate space shrinks. Must-link constraints act on the reported rules.
  • Item-specific minimum supports let rare but important items survive the frequency filter, the problem that Liu, Hsu & Ma (1999) address with multiple minimum supports.
  • Output rules carry support, confidence and lift, so each rule can be checked by a domain expert against its frequency and its association strength.
  • The method works on categorical transaction records and does not require a target label for every record.

Applications

  • Market-basket analysis in which merchandising rules or product-category groupings are used to decide which item combinations are worth reporting.
  • Clinical decision support, where known drug interactions could be encoded as cannot-link constraints so that they are not reported as associations of interest.
  • Web usage mining, where user-profile labels could restrict the search to the behaviour of a chosen user segment.
  • Transaction-log analysis for fraud, in which previously labelled fraud cases could seed the constraints that guide which patterns are examined.
  • Educational data mining, where curriculum prerequisites could be encoded so that the discovered learning-path patterns are checked against them.

How it works

How it works

1

Domain knowledge is written down as explicit constraints before mining. Must-link constraints require that certain items appear together in a reported rule; cannot-link constraints forbid a pair of items from co-occurring; item-specific minimum supports let rare but important items keep a lower threshold than the global minimum. Liu, Hsu & Ma (1999) motivate the item-specific case: a single minimum support either misses rules involving rare items or, if set low, produces a combinatorial explosion among frequent items.

2

As in classic Apriori (Agrawal & Srikant, 1994), frequent (k-1)-itemsets are joined to form candidate k-itemsets. Cannot-link constraints are applied to these candidates so that the number of candidates counted against the database is reduced.

Formula
C_k = \text{Apriori-gen}(L_{k-1})
3

Before any database scan, candidates that contain a cannot-link pair are discarded. A candidate containing such a pair cannot yield a permitted rule, so removing it does not remove any permitted rule. Must-link constraints are not used to discard candidates during the level-wise search, because a candidate that lacks a must-link pair may still be needed to build larger frequent itemsets; they are applied to the frequent itemsets or to the output rules instead. Item-specific minimum supports are applied when support is counted, not at this step.

4

Surviving candidates are counted over the transaction database. Support is the fraction of transactions that contain the itemset. An itemset advances to the next level only if it meets its minimum support, which may be item-specific as in the multiple-minimum-support approach of Liu, Hsu & Ma (1999).

Formula
\text{support}(X) = \frac{|\{t \in T : X \subseteq t\}|}{|T|}
5

Association rules X → Y are generated from the frequent itemsets and filtered by confidence, the ratio support(X ∪ Y) / support(X). Lift, the ratio of confidence to the support of the consequent Y, is used as a further filter in practice; it is not part of the mechanics formulas on this page. Background constraints restrict the output: a must-link pair must appear within X ∪ Y, and the consequent Y can be required to belong to a category of interest.

Formula
\text{confidence}(X \Rightarrow Y) = \frac{\text{support}(X \cup Y)}{\text{support}(X)}

Common pitfalls

  • Using one high global minimum support causes rules that involve rare items to disappear; item-specific thresholds are the approach the cited multiple-minimum-support work proposes for this case.
  • Reading a high-confidence rule as causal. The rule records co-occurrence in the transactions and says nothing about cause.
  • Judging a rule by confidence alone. If the consequent is very frequent, a high-confidence rule can still have lift close to or below 1, meaning it is no more informative than the base rate of the consequent.
  • Specifying a must-link and a cannot-link constraint on the same item pair. The two requirements contradict each other; without a rule for resolving the conflict, the rules involving that pair can silently disappear from the output.
  • Choosing discretisation boundaries for numerical attributes without checking them. Different bin boundaries can change which itemsets pass the support threshold, so the rule set should be compared across reasonable binning choices.

Frequently asked questions

How is this different from plain Apriori?

Plain Apriori applies one global minimum support and returns every frequent itemset above it, which can produce a very large rule set. The constrained variant also takes domain knowledge: cannot-link item pairs are excluded from candidates during the search, must-link pairs require that the items appear together in reported rules, and item-specific minimum supports let rare items pass a lower threshold. The output is therefore restricted to rules consistent with that knowledge.

Do I need labeled data to use this method?

No. The constraints can come entirely from domain expertise, expressed as forbidden combinations, required co-occurrences or item-specific supports, without any labelled records. The word 'semi-supervised' in the name is a descriptive label and does not by itself require labels. If labelled examples exist, they can help decide which constraints to write, but the thresholds are set by the analyst.

When should I prefer FP-Growth over semi-supervised Apriori?

FP-Growth avoids explicit candidate generation and is generally preferred when the goal is to mine all frequent itemsets from a large dataset without special constraints. The constrained Apriori variant is more suitable when item-level constraints or background knowledge must shape the search, because cannot-link exclusions and item-specific thresholds are applied during candidate generation and support counting.

How do I choose minimum support and confidence thresholds?

Set the global minimum support according to how common the patterns you expect to find are, and lower it for items of special interest so that rare items are not excluded. Set the minimum confidence high enough to remove weak rules but not so high that only obvious rules remain. Check whether the surviving rules are stable when the thresholds are varied slightly, and review the lift values alongside confidence.

Can semi-supervised Apriori handle numerical features?

Not directly. Numerical attributes must first be discretised into categorical bins. The bin boundaries are a separate modelling decision that strongly affects which itemsets are frequent, so the rule set should be compared across several reasonable binning strategies before results are interpreted.

Related methods

Sources

  1. Agrawal, R., & Srikant, R. (1994). Fast algorithms for mining association rules. Proceedings of the 20th International Conference on Very Large Data Bases (VLDB), 487–499.

    Open publication reference
  2. Liu, B., Hsu, W., & Ma, Y. (1999). Mining association rules with multiple minimum supports. Proceedings of the 5th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 337–341.

    Open DOI reference