Skip to main content

πŸ“ Probability & Statistics

Conditional probability​

P(y=1∣x)P(y=1 \mid x)

means the probability that the outcome yy equals 1, given that we know the input features xx.

The vertical bar ∣\mid means β€œgiven” or β€œconditioned on.”

Example​

Suppose we want to predict whether a user will book a listing:

  • y=1y=1: the user books
  • y=0y=0: the user does not book
  • xx: information about the user, listing, and trip

For example:

x=[price,location,rating,tripΒ dates,userΒ history]x = [\text{price}, \text{location}, \text{rating}, \text{trip dates}, \text{user history}]

If the model estimates:

P(y=1∣x)=0.08P(y=1 \mid x)=0.08

it means that, given these user, listing, and trip features, the estimated probability of booking is 8%.

Because this is binary classification:

P(y=0∣x)=1βˆ’P(y=1∣x)P(y=0 \mid x)=1-P(y=1 \mid x)

Therefore:

P(y=0∣x)=1βˆ’0.08=0.92P(y=0 \mid x)=1-0.08=0.92

In logistic regression​

A logistic-regression model calculates:

z=θ⊀x+βz=\theta^\top x+\beta

and transforms it into a probability using the sigmoid function:

P(y=1∣x)=Οƒ(z)=11+eβˆ’zP(y=1 \mid x) =\sigma(z) =\frac{1}{1+e^{-z}}

For example, if z=1.5z=1.5:

P(y=1∣x)=11+eβˆ’1.5β‰ˆ0.818P(y=1 \mid x) =\frac{1}{1+e^{-1.5}} \approx 0.818

The model predicts an approximately 81.8% probability that y=1y=1.

Important interpretation​

This probability applies to observations with features like xx; it does not guarantee what will happen in one individual case.

If:

P(y=1∣x)=0.8P(y=1 \mid x)=0.8

a well-calibrated model should produce positive outcomes for approximately 80% of many similar examples. One specific example can still have y=0y=0.