# How was $\frac{P_t(x)}{P_s(x)} = \frac{P(\delta = 1)}{P(\delta = 0)} \left( \frac{1}{P(\delta = 1 \mid x)} - 1\right)$ derived?

I am currently studying Transfer Learning by Qiang Yang, Yu Zhang, Wenyuan Dai, and Sinno Jialin Pan. Chapter 2.2.1 Discriminatively Distinguish Source and Target Data says the following:

One simple and effective approach to learn the weights is to transform the problem of estimating the marginal probability density ratio to the problem of distinguishing whether an instance is from the source domain or the target domain. This can be formulated as a binary classification problem with data instances from the source domain being labeled as $$1$$ and those from the target domain being labeled as $$0$$.

For example, Zadrozny (2004) proposes a rejection sampling-based method for correcting sample selection bias. The rejection sampling process is defined as follows. A binary random variable $$\delta \in \{1, 0 \}$$, which is called selection variable, is introduced. An instance $$\mathbf{\mathrm{x}}$$ is sampled from the target marginal distribution $$\mathbb{P}_t^X$$ with probability $$P_t(\mathbf{\mathrm{x}})$$, that is, $$P_t(\mathbf{\mathrm{x}}) = P(\mathbf{\mathrm{x}} \mid \delta = 0)$$. Similarly, $$P_s(\mathbf{\mathrm{x}})$$ can be rewritten as $$P_s (\mathbf{\mathrm{x}}) = P (\mathbf{\mathrm{x}} \mid \delta = 1)$$. $$\mathbf{\mathrm{x}}$$ is accepted by the source domain with probability $$P (\delta = 1 \mid \mathbf{\mathrm{x}})$$ or rejected with probability $$P (\delta = 0 \mid \mathbf{\mathrm{x}})$$. In mathematics, with the new variable $$\delta$$, the density ratio for each data instance $$\mathbf{\mathrm{x}}$$ can be formulated as
$$\dfrac{P_t(\mathbf{\mathrm{x}})}{P_s(\mathbf{\mathrm{x}})} = \dfrac{P(\delta = 1)}{P(\delta = 0)} \dfrac{P(\delta = 0)}{P(\delta = 1)} \dfrac{P_t(\mathbf{\mathrm{x}})}{P_s(\mathbf{\mathrm{x}})}, \tag{2.5}$$ where $$P (\delta)$$ is the prior probability of $$\delta$$ in the union data set of the source domain and the target domain. By using the Bayes, rule and the equivalent forms of $$P_s (\mathbf{\mathrm{x}})$$ and $$P_t (\mathbf{\mathrm{x}})$$ in terms of $$\delta$$, (2.5) can be further reformulated as $$\dfrac{P_t(\mathbf{\mathrm{x}})}{P_s(\mathbf{\mathrm{x}})} = \dfrac{P(\delta = 1)}{P(\delta = 0)} \left( \dfrac{1}{P(\delta = 1 \mid \mathbf{\mathrm{x}})} - 1\right).$$ Therefore, the density ratio for each source domain data instance can be estimated as $$\dfrac{P_t(\mathbf{\mathrm{x}})}{P_s(\mathbf{\mathrm{x}})} \propto \dfrac{1}{P_{s, t}(\delta = 1 \mid \mathbf{\mathrm{x}})}$$. To compute the probability $$P(\delta = 1 \mid \mathbf{\mathrm{x}})$$, we regard it as a binary classification problem and train a classifier to solve it. After calculating the ratio for each source data instance, a model can be trained by either reweighting each source data instance or performing importance sampling on the source data set.

I think this is Zadrozny (2004).

I am confused by this part:

$$\dfrac{P_t(\mathbf{\mathrm{x}})}{P_s(\mathbf{\mathrm{x}})} = \dfrac{P(\delta = 1)}{P(\delta = 0)} \left( \dfrac{1}{P(\delta = 1 \mid \mathbf{\mathrm{x}})} - 1\right).$$

I have been unable to derive this from (2.5). Furthermore, I don't really see how this can be derived using Bayes's rule, since there is a $$-1$$ additive term, whereas everything in (2.5) and Bayes's rule is multiplicative. Is this an error? Otherwise, how does one derive this from (2.5)?

• Does anyone know why "-1" was omitted, going from $\frac{1}{P(\sigma=1|x)}-1$ to $\frac{1}{P_{s,t}(\sigma=1|x)}$? May 10, 2021 at 22:41

I didn't review all the context, but the conversion is straightforward: \begin{align}\frac{1}{P(\delta=1|x)}-1&=\frac{P(\delta=0|x)}{P(\delta=1|x)}=\frac{P(\delta=0|x)P(x)}{P(\delta=1|x)P(x)}\\&=\frac{P(\delta=0)P(x|\delta=0)}{P(\delta=1)P(x|\delta=1)}\\&=\frac{P(\delta=0)}{P(\delta=1)}\frac{P_t(x)}{P_s(x)}\end{align}
• How did you get $\frac{P(\delta=0|x)P(x)}{P(\delta=1|x)P(x)} = \frac{P(\delta=0)P(x|\delta=0)}{P(\delta=1)P(x|\delta=1)}$? Nov 15, 2020 at 8:14
• Using Bayes Formula: $P(A)P(B|A)=P(A|B)P(B)$ Nov 15, 2020 at 8:14
• And how did you get $\frac{1}{P(\delta=1|x)} - 1 = \frac{P(\delta=0|x)}{P(\delta=1|x)}$? Nov 15, 2020 at 8:20
• $1-P(\delta=1|x)=P(\delta=0|x)$ Nov 15, 2020 at 8:21