Conditional Probability

Conditional probability measures the probability of an event occurring, given that another event has already occurred. It's a foundational concept in statistics and forms the mathematical basis for confidence in association rule mining.

The Formula

P(A|B) = P(A and B) / P(B)

This reads as "the probability of A given B" and is calculated by dividing the probability of both A and B occurring together by the probability of B occurring on its own.

A Simple Example

Suppose in a set of 100 customer transactions, 40 include both bread and butter, and 50 include bread overall. The probability of a customer buying butter given that they bought bread is:

P(Butter | Bread) = 40/100 / 50/100 = 0.8

Meaning there's an 80% chance a customer who bought bread also bought butter.

Connection to Association Rules

This is exactly how confidence is calculated in association rule mining - the confidence of a rule A -> B is nothing but the conditional probability P(B|A), the likelihood of B being purchased given that A was already purchased.

Independence

Two events are said to be independent if the occurrence of one doesn't affect the probability of the other - in that case, P(A|B) simply equals P(A).

Conditional probability is easy to misinterpret - P(A|B) is not the same as P(B|A); mixing these up is one of the most common statistical errors, sometimes called the "prosecutor's fallacy."

Coming Up Next

With conditional probability in place, you're ready for the final topic of this section - the Lift Ratio, which builds directly on this concept.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course