liveBook · Manning

Apriori algorithm

As explained in Outlier Detection in Python

The Apriori algorithm discovers frequent item sets by progressively extending item combinations that satisfy a minimum support criterion.

Apriori discovers frequent item sets by progressively extending combinations that meet a minimum support threshold. Its output can describe common records and support interpretable outlier scoring. section 3.2.4

Apply it to categorical or discretized tabular data by:

  • Bin dates, times, and amounts when interpretability benefits from categorical values. section 3.2.4
  • One-hot encode every feature, then represent zero and one values as Boolean indicators. section 3.2.4
  • Run mlxtend.apriori with a chosen minimum support and optionally restrict item-set size. section 3.2.4
  • Use the returned support and itemsets columns to compare how many frequent patterns each row contains. section 3.2.4

SpeedDating frequent item sets

With minimum support 0.3, the procedure finds common preferences such as ambitious scores [0–15] and shared-interests scores [0–15], plus their combination. These patterns contribute to FPOF scores: the most inlier row scores 0.0, while the most outlier row scores 1.0. section 3.2.4

Table 3.4 Staff expenses with binned values (view table figure)

Row

Staff ID

Department

Account

Date of expense

Date submitted

Time submitted

Amount

1

9000483

Sales

Meals

2

2

9

2

2

9303332

Marketing

Travel

2

2

10

2

3

9847421

Engineering

Meals

2

2

10

3

4

9303332

Marketing

Supplies

2

2

11

3

5

9000483

Sales

Meals

2

2

11

2

6

9000483

Sales

Meals

2

2

12

2

Inspect the binned expense data used to turn dates, times, and amounts into interpretable categorical values before one-hot encoding. section 3.2.4

How Outlier Detection in Python covers it

How deep it goes
Explains encoding, support selection, size restrictions, output inspection, and scoring, but does not derive Apriori internals.
Examples
Demonstrates staff expenses, binned transactional features, and SpeedDating preference combinations.
What it assumes
Assumes tabular feature handling and introduces one-hot encoding, Boolean indicators, support, and discretization in context.
What you can do after
Apply Apriori through mlxtend to mine frequent item sets and support interpretable FPOF-based outlier scoring.
How it connects
Connects frequent item sets with one-hot encoding, minimum support, FPOF, and outlier detection.

Also explained in

Compare how 2 books explain Apriori algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.