# How do I intuitively interpret $P(\text{data}|\text{class}=1)$ and $P(\text{data})$

How do I intuitively interpret $$P(\text{data}|\text{class}=1)$$ and $$P(\text{data})$$ from $$P(\text{class}=1|\text{data})=\frac{P(\text{data}|\text{class}=1)P(\text{class}=1)}{P(\text{data})}$$

I understand the Bayes theorem, however I can't really understand how to interpret exactly $$P(\text{data}|\text{class})$$ and $$P(\text{data})$$. Let me give you an example of data and a class so maybe you can understand what I don't understand better:

Suppose we observe a sample of $$S$$ women with breast cancer, such that we have only one variable (a stupid simple variable for our example) for our predictor data $$x$$ = age which spans from $$0$$ to $$100$$ (suppose $$100$$ is the maximum age a person can get to) and the response is $$Y=1$$ if the woman has breast cancer and $$0$$ otherwise. There are $$20\%$$ who have breast cancer from $$S$$. I don't know if this would help, but let's assume for simplicity that from the age of 0 to 25 women don't get cancer, from 25 to 75 women do have cancer and from 75 to 100 women dont have cancer.

So:

$$P(\text{class}=1)=0.2$$ is straighforward.

But what does $$P(\text{data}|\text{class}=1)$$ mean? Does it mean the probability of an age given the women has breast cancer? What does that even mean?

What does $$P(\text{data})$$ mean? Probability of having an age?

If someone could explain me through this example, or through some other example the meaning of these probabilities, that would be great. If there are any resources that you know which could explain this to me in more detail, I would also be grateful for those.

• Actually , $P(class=1|data)=0.2$ because you derive it from the data, it's not a prior. May 19 at 9:18
• @gunes okay, well assume that $P(class=1|data)=P(class=1)$ in this case May 19 at 9:22

But what does 𝑃(data|class=1) mean? Does it mean the probability of an age given the women has breast cancer?

Yes, think about filter. Suppose you have a lot of data, each record has two fields, age and if this person had breast cancer. 𝑃(data|class=1) means we first filter the data with all people that had breast cancer, and then look the distribution of their age. If we plot the histogram, you may see something like this.

On the other hand, if we do P(data|class=0), you may see a similar shape but the center on the left side (have younger age)

You can think 𝑃(data) is a constant, because the data/observation is given.

• (+1) It's a good practical view for sample size = 1. May 19 at 9:37

P(data)

That's how I read it: It's the probability of observing the given datapoint(s) in the population you are working on. For example, your dataset is a woman of age 75 (so data = 75) and in your study population there are 5% of women in the age bracket [74.5, 75.5) then P(data) = 0.05. If your dataset is two women of age 75 then P(data) = 0.05 * 0.05 = 0.0025.

P(data|class=1)

It's the same as above but this time you don't consider the entire population of women but only the subset belonging to class 1. So if in class 1 the age bracket [74.5, 75.5) makes up 7% of women, then P(data= {75, 75} | class=1) is 0.0049

Literally, $$P(\text{data})=P(\mathcal D)=P(X_1=x_1...X_n=x_n)$$ is the probability of obtaining the data you have. It is sometimes a probability density (e.g. when the data is continuous). In that case, we refer to it as $$f_{\mathbf X}(x_1...x_n)$$ and the conditional density is referred as $$f_{\mathbf X|Y=y}(x_1...x_n)$$. So, if you were to sample $$n$$ data points from the population, what would be the probability/likelihood of obtaining your data.

Similarly, $$P(\mathcal D|Y=1)$$ means that if you were to sample $$n$$ data points with $$Y=1$$ label from population, what would be the likelihood/probability of obtaining the data you have at hand, regardless of the labels of individual samples, .e.g. if your data has one sample, $$x=30$$ (age), $$P(x=30|Y=1)$$ means the probability of picking a 30-age person amongst people with breast cancer.