where \(y_{s=1}\)  denotes the ground-truth label from the seen imbalanced domain and \(y_{s=0}\)  denotes the supervision from the unseen balanced domain. Here remain two questions. First, how to obtain \(y_{s=0}\) . As mentioned above, we cannot directly draw samples \((x,y_{s=0})\)  from the unseen domain \(S\!=\!0\) . Fortunately, thanks to the causality-based framework [1]}, this can be simulated by
counterfactual inference that deducts the “head” prior effect from the factual effect. In this way, we can obtain the counterfactual \((x,y_{s=0})\)  based on the factual \((x,y_{s=1})\) .
In particular,
\(y_{s=0}\)  is estimated from the balanced classifier \(p^\text{ba}(y|x)\)  described in Step 1 and denoted as \(\hat{y}\)  in Step 3 of the algorithm.
Second, how to obtain the sample weights \(\frac{P(x)}{P(x|S)}\) .
Since \(\frac{P(x)}{P(x|s)}=\frac{P(s)}{P(s|x)}\)  and we assume \(P(S\!=\!1)=P(S\!=\!0)\) . Therefore, we have \(\frac{P(x)}{P(x|s)}\propto \frac{1}{P(s|x)}\) .
In essence, they are inverse probabilities of how likely the sample \(x\)  is from the imbalanced training domain (\(S=1\) ) and from the balanced domain (\(S=0\) ). Inspired by this, we propose to use the
cross-entropy loss \(X\!E\)  to delineate the discrepancy between the imbalanced and balanced domains and estimate the weights:
\(\begin{split}w^\text{imba}&\propto \frac{1}{P(S=1|x)}\propto {(X\!E^\text{imba})^\gamma },\\w^\text{ba}&\propto \frac{1}{P(S=0|x)}\propto {(X\!E^\text{ba})^\gamma }.\end{split}\) 
