liveBook · Manning

Marginal probability

As explained in Outlier Detection in Python

A marginal distribution describes the probability behavior of one variable after accounting for or aggregating over the other variables.

A marginal probability measures how often one feature value occurs without considering the values of other features. It comes from a table margin: divide a feature value's count by the total number of rows. This separates values that are individually rare from combinations that are unusual despite having ordinary marginal frequencies. section 2.4.2

Use marginal probabilities to assess whether a rare combination is rare for an ordinary reason or is unusual in its joint behavior:

  • Compute each feature value's marginal fraction from its row or column total. section 2.4.2
  • Estimate an expected combination count by multiplying the relevant marginal fractions and the dataset size, under the independence-based estimate. section 2.4.2 section 3.1.1
  • Compare observed and expected counts to distinguish combinations of rare values from combinations that are unexpectedly sparse or frequent. section 2.4.2 section 13.3.3
  • Apply the comparison to missing or unusually low combinations, including pairs or triples when the dataset is sufficiently large. section 12.5

Separating marginal rarity from combination rarity

In a table with 975,257 rows, value A occurs 1,513 times and value W occurs 3,014 times, giving marginal fractions of about 0.001 and 0.003. Their observed combination occurs twice, while multiplying those fractions predicts about 4.6 rows. The combination is rare, but both component values are already rare. By contrast, a combination of individually common values can be flagged when its observed count is far below its marginally expected count.

Marginal probabilities also support algorithmic detectors. COPOD uses empirical cumulative distributions and an empirical copula to estimate tail probabilities, while CountsOutlierDetector can check marginal probabilities when scoring sparse categorical subspaces. These methods improve interpretation but do not make every flagged combination meaningful automatically. section 6.4 section 13.3.3

How Outlier Detection in Python covers it

How deep it goes
Explains table margins, expected counts, actual-to-expected ratios, independence assumptions, and detector applications.
Examples
Uses contingency tables, missing staff-product combinations, categorical subspaces, and COPOD examples.
What it assumes
Assumes feature-combination counts and basic fractions, then derives marginal probabilities from table margins.
What you can do after
Evaluate/understand whether a rare combination reflects rare component values or an unexpected relationship among ordinary values.
How it connects
Connects marginal probability to joint probability, independence, outlier detection, empirical distributions, and copulas.

Also explained in

Compare how 3 books explain marginal probability →

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.